gsr_30
Joined: 31 Oct 2010 Posts: 1
|
char and string operation |
Posted: Mon Nov 01, 2010 1:51 pm |
|
|
Hi,
I'm trying to make a program that processes characters and strings, with a PIC18F4550 connected to a computer through the UART.
The program consists of a ring-buffer that receives characters from the hyperterminal and when 'w' is typed it will write the next characters in a string, until '.' is typed or until the number of characters exceeds 16.
So I did some programs, but none of them worked ... the PIC receives characters (send them back), puts them in a buffer (send it to the computer) but when it copys characters from the buffer to a string and send the string to the hyperterminal it shows nothing...
Then I found in this forum a link to a code that apparently many people have tested and worked with them,
http://www.todopic.com.ar/foros/index.php?PHPSESSID=ce6a0a91c9835a53397bb2ad634182bb&topic=4573.0
but the same problem happens (the string processed by the code is not shown in hyperterminal).
This is an example of what's happening but with BYTEs or characters:
This code is an example that comes with the ccs, EX_SISR.C, but with a small change (in the main code I added the variable b, then b=bkhit(), and sent b to the computer) :
Code: |
void main() {
BYTE b;
enable_interrupts(int_rda);
enable_interrupts(global);
printf("\r\n\Running...\r\n");
do {
delay_ms(10000);
printf("\r\nBuffered data => ");
while(bkbhit)
b=bgetc() ;
putc( b );
} while (TRUE);
}
|
But when before the code change, if I send "aaa" it would return "Buffered data => aaa", after the change it just returns "Buffered data => a".
Can someone tell me what might be the problem?
Thanks in advance.
Gil |
|