Comments on: Using UART of PIC Microcontroller – Hi Tech C https://electrosome.com/uart-pic-microcontroller-hi-tech-c/ You Inspire.....We Create..... Tue, 28 Feb 2017 07:32:00 +0000 hourly 1 https://wordpress.org/?v=6.1.1 By: arvind pandi https://electrosome.com/uart-pic-microcontroller-hi-tech-c/#comments/6670 Tue, 28 Feb 2017 07:32:00 +0000 https://electrosome.com/?p=7202#comment-6670 sir ,
i took ur code as reference and wrote the following code,but whenever i read a string ,the following code isint working,can u help me with this
#include
#include
#include

#define _XTAL_FREQ 4000000

__CONFIG(FOSC_HS & WDTE_OFF & PWRTE_OFF & BOREN_ON & LVP_OFF);

/******************************BASIC CONFIGURATION SETTINGS********************/

void UART_Init()
{
TXSTA = 0x24;
RCSTA = 0x90;
SPBRG = 25;
TRISC=0x80;
}

/*************************TO WRITE A CHAR TO SERIAL PORT*****************************/

void UART_Write(char data)
{
TXREG = data; //Writing data to Transmit Register, Starts transmission
while(!TXIF); // stay until TXIF remains 0, if TXIF =1 indicates successfully transmitted previous bit ready to transmit next
TXIF = 0; //Waiting for Previous Data to Transmit completly
}

/***************To Write a string to serial*******************************/
void UART_Write_Text(char *text)
{
int i;
for(i=0;text[i]!=”;i++)
{
UART_Write(text[i]);
}
UART_Write(‘~’);
}
/*****************************to read a char from serial**************************/

char UART_Read()
{

while(!RCIF); //Waits for Reception to complete
return RCREG; //Returns the 8 bit data
}

/*******************************to read a string to serial**********************************/

void ReadString(char *outstring)
{

char data;
char dataout[30]={0};
int index = 0;
memset(outstring,0,20);
memset(dataout,0,20);
data=UART_Read();

while(data!= ‘~’)
{

dataout[index++] = data;
data=UART_Read();
}
dataout[index++]=’n’;
dataout[index]=”;
memcpy(outstring, dataout, index);

}

/*********************main function************************/

void main()
{
UART_Init(); //initiate uart
int i=0;
char b[10]=”arvind~”;
char a[10];
while(1)
{
UART_Write_Text(b);
ReadString(a);
//__delay_ms(100);

//UART_Write_Text(a);

}
}

]]>
By: Ligo George https://electrosome.com/uart-pic-microcontroller-hi-tech-c/#comments/6251 Sat, 27 Aug 2016 07:04:00 +0000 https://electrosome.com/?p=7202#comment-6251 In reply to jaydip.

Above program is with Hi-Tech C. Kindly use the following link for MikroC
https://electrosome.com/pic-to-pic-communication-uart/

]]>
By: Yolcos https://electrosome.com/uart-pic-microcontroller-hi-tech-c/#comments/6169 Mon, 20 Jun 2016 16:52:00 +0000 https://electrosome.com/?p=7202#comment-6169 In reply to jaydip.

I have a same problem, I nedd receive a text.

]]>
By: Ligo George https://electrosome.com/uart-pic-microcontroller-hi-tech-c/#comments/5763 Sun, 24 Jan 2016 06:00:00 +0000 https://electrosome.com/?p=7202#comment-5763 In reply to Gulzar.

Sorry, I don’t understand your question.

]]>
By: Gulzar https://electrosome.com/uart-pic-microcontroller-hi-tech-c/#comments/5734 Sat, 02 Jan 2016 05:42:00 +0000 https://electrosome.com/?p=7202#comment-5734 Hi, in the UART_Write function how can you check for the break character ‘\0’ when it is larger than one byte? I’m confused. Thx for your help.

]]>
By: Ramesh https://electrosome.com/uart-pic-microcontroller-hi-tech-c/#comments/4980 Tue, 30 Jun 2015 07:37:00 +0000 https://electrosome.com/?p=7202#comment-4980 hi

]]>
By: Ligo George https://electrosome.com/uart-pic-microcontroller-hi-tech-c/#comments/4873 Sat, 06 Jun 2015 10:19:00 +0000 https://electrosome.com/?p=7202#comment-4873 In reply to ranjith.

You can use the same configuration bits that used in the first tutorial, https://electrosome.com/blinking-led-pic-microcontroller-hi-tech-c/

]]>
By: ranjith https://electrosome.com/uart-pic-microcontroller-hi-tech-c/#comments/4822 Thu, 28 May 2015 10:26:00 +0000 https://electrosome.com/?p=7202#comment-4822 what are the configuration bits for serial communication if i used port b as

]]>
By: Ligo George https://electrosome.com/uart-pic-microcontroller-hi-tech-c/#comments/4348 Mon, 23 Mar 2015 09:40:00 +0000 https://electrosome.com/?p=7202#comment-4348 In reply to prem.

You can use the same code of MPLAB XC8.. just change the header file xc.h to htc.h.
https://electrosome.com/em-18-rfid-module-pic/

]]>
By: prem kumar https://electrosome.com/uart-pic-microcontroller-hi-tech-c/#comments/4331 Thu, 19 Mar 2015 17:20:00 +0000 https://electrosome.com/?p=7202#comment-4331 hai….
i ned project program for Hi Tech c
title is show rfid code in lcd 2*16 display… pic16f877a

]]>