If you can send one ascii character then you can send many ascii characters.
This implies you can send strings to PIC from your PC, Right???
The only problem i guess You are facing is storing, Right???
Do you want to store it permanently or temporaryly?
If youy need to store temporarily then you can store it in a variable and send it to the LCD routine.
Well when Integer 1234 is sent to the PIC over a serial link it first converted to string, Then character by character it us sent to the PIC.
On PIC side you should take care how to convert it back or how to manipulate.
Hope this helps.
Yup, i could'nt find the way on catching the single character and store it as one string, then assign the string to one variable, i'm going to store the string temporary with a variable, do you have any example to do so? i'm using ccs pic c compiler.
Global :
unsigned int i;
unsigned char a[20]="" ; //empty string of 19 char + '\0'
void MyReadString()
{
for(i=0 ; i<19 ; i++)
{
a[i] = UART_Receive_char();
}
a[i] = '\0';
}
Well To receive a string on PIC side you should know how the UART_Read_Char() functions. and There must be a terminating condition.
so if I write a function to read a string then it may look like this ++++ THIS IS PSEUDO CODE +++++
Code:Global : unsigned int i; unsigned char a[20]="" ; //empty string of 19 char + '\0' void MyReadString() { for(i=0 ; i<19 ; i++) { a[i] = UART_Receive_char(); } a[i] = '\0'; }
OK, before i try with this method, i would like to know on the GUI side, do i need to send 1 character at a time or i can send directly 1 string to be read by PIC?
GUI side ??? do you mean on PC side???
If the above assumption is true then you have to send a string not more than 19 chars or better send char by char.
for(i=0;i<5;i++)
{
string[i]=getc();
}
lcd_gotoxy(1,1);
printf(lcd_putc,"Read=%s",string);
Code:for(i=0;i<5;i++) { string[i]=getc(); } lcd_gotoxy(1,1); printf(lcd_putc,"Read=%s",string);
i tried to use the above code, it works fine if i send 5 character at one time, and display it correctly, but it wont work if i send less then 5 character, program will wait until 5 character has been read and display it on LCD, do you have any idea on how am i going to solve this, since the character that will be send to PIC is not fix.
So you got something working.
if you just change the loop and check the EOL character then you are done. Try it.
Yup, thanks to you ;-). But i did'nt quite understand on changing the loop and check for EOL, can you give some example and a little explanation.
while(true)
{
lcd_gotoxy(1,1); // Column,Row
printf(lcd_putc,"Read=%s",string);
while(getc()!='\n')
{
for(i=0;i<5;i++)
{
string[i]=getc();
}
}
}
Code:while(true) { lcd_gotoxy(1,1); // Column,Row printf(lcd_putc,"Read=%s",string); while(getc()!='\n') { for(i=0;i<5;i++) { string[i]=getc(); } } }
i tried to use the above code, but it wont work, displayed string is not the same as entered, can you tell me what's wrong?
i changed it, but still not working :sad:
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?