This is My First post to this Forum....
suggest me which is the best way to receive string from serial port by using own functions with out using standard library.....
Fixed Char array or by using pointers??
Please Help me to receive strings from serial port of a microcontroller using C..
I Established the communication with controller and the function getchar() can receive one charector at a time from serial port succesfully..
Code:
/******************************************************************************/
/* SERIAL.C */
/******************************************************************************/
#include <controllerxx.H>
#define NULL '/0'
/* implementation of getchar */
int getchar (void) { /* Read character from Serial Port */
while (!(U1LSR & 0x01)); //Don't care about this this is controller registors
return (U1RBR);
}
//Here is my code start.... getchar() function can read one charector at time from serial port
All I need to do is store this to a variable and whenever iam calling from main function it should display the string...
//Function defenitions
unsigned char string_receive(void)
{
static char uart_data[200];
static char count=0;
while(uart_data[count]!=NULL)
{
uart_data[count]=getchar();
count++;
}
return uart_data[200];
}
int main (void)
{
char abc[200];
init_serial (); /* Initialized Serial Interface ..its OK I can receive Char.. */
abc[200]=string_receive();
display(abc);
}