Swys
Junior Member level 1
pic18f452 uart
Hi all,
I was wondering if anyone could help me on this. I am working on MPLAB with a PIC18F452 and the HI-TECH compiler. I want to write a function which must be able to receive a string of characters from the UART. I enter this string on my terminal program.
I am able to receive a single character, but i want to receive a whole string of characters.
I've been struggeling with this for a while now. If anyone can help I would greatly appreciate it!
Hi all,
I was wondering if anyone could help me on this. I am working on MPLAB with a PIC18F452 and the HI-TECH compiler. I want to write a function which must be able to receive a string of characters from the UART. I enter this string on my terminal program.
I am able to receive a single character, but i want to receive a whole string of characters.
Code:
//Receive one character
unsigned char getch()
{
while (!RCIF)
continue;
return RCREG;
}
Code:
//Input a series of characters into the specified buffer
//NOT WORKING!!!
void gets(char *s)
{
char c = 0;
while (c != '\0')
{
c = getch();
*s = c;
*s++;
}
}
I've been struggeling with this for a while now. If anyone can help I would greatly appreciate it!