View previous topic :: View next topic |
Author |
Message |
Jens Guest
|
printf only works with 2 blanks |
Posted: Tue Jan 17, 2006 4:58 am |
|
|
Hello,
I work with MPLAB 7.22 and CCS-Compiler PCB/PCM 3.180. With the printf-comand I want to send some data with RS232 to the PC where I use a hyperterminal.
First my sourcecode:
#include <16F876.h>
#FUSES HS,NOWDT,NOLVP
#use delay(clock=4000000)
#USE RS232 (BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7)
int i;
void main (void)
{
printf("HelloWorld");
}
In the terminalprogramm (either from Microsoft or HTerm) I don't receive the last two letters. There's only "HealloWor"
If I want to send an Integer, I also have to add two blanks so that it works:
printf("%d ",i) works...
printf("%d",i) doesnt't work at all...
Do you know this kind of problem? |
|
![](templates/subSilver/images/spacer.gif) |
carlosma
Joined: 24 Mar 2004 Posts: 53 Location: Portugal
|
|
Posted: Tue Jan 17, 2006 5:19 am |
|
|
Hello
Do this:
Code: |
void main (void)
{
printf("\r\nHelloWorld\r\n");
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
TIMT
Joined: 02 Sep 2005 Posts: 49 Location: Nottingham, UK
|
|
![](templates/subSilver/images/spacer.gif) |
Jens Guest
|
|
Posted: Tue Jan 17, 2006 6:16 am |
|
|
Thanks a lot, that is very interesting, and it works know!!
You just have to keep the controller busy until everything is send.
I use a "delay" for example know. |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue Jan 17, 2006 7:58 am |
|
|
I'll bet you are using a hardware UART with a 2 character buffer. Once the last two characters are loaded into the buffer the program "falls off the end of the code" and processing stops. Those last two characters are forever marooned in the buffer.
Try:
Code: |
void main (void)
{
printf("HelloWorld");
while(1);
}
|
This will keep the processor running so the UART can crank out thoses last 2 characters. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
|