|
|
View previous topic :: View next topic |
Author |
Message |
mvaraujo
Joined: 20 Feb 2004 Posts: 59 Location: Brazil
|
Printf output problem? |
Posted: Mon Jul 05, 2004 7:56 am |
|
|
Hi all,
I have something like this on my code:
Code: | printf(disp_store,"%03lu.%1uV %02u.%1uHz",v_rms,v_rms_dec,freq,freq_dec); |
It seams that sometimes it didn't output 16 characters but one less. Did you guys experience any problems like that on printf command?
Thanks!
Marcus |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jul 05, 2004 11:47 am |
|
|
Quote: | It seems that sometimes it didn't output 16 characters but one less |
I made a test file and compiled it for the 16F877 with PCM vs. 3.188.
It works. I changed the printf statement to remove the output
to "disp_store", and instead I sent it to my terminal window.
I also added a 2nd line, which shows the character count.
Here are the results displayed in the terminal window:
Code: | 012.3V 04.5Hz
1234567890123456 |
Here is the test program:
Code: | #include <16F877.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//===============================
main()
{
int16 v_rms;
int8 v_rms_dec;
int8 freq;
int8 freq_dec;
v_rms = 12;
v_rms_dec = 3;
freq = 4;
freq_dec = 5;
printf("%03lu.%1uV %02u.%1uHz",v_rms,v_rms_dec,freq,freq_dec);
printf("\n\r1234567890123456\n\r");
while(1);
} |
If this reply does not fix your problem then you should post
your own test program that demonstrates the problem, and
also give the PIC and the version of your compiler. |
|
|
mvaraujo
Joined: 20 Feb 2004 Posts: 59 Location: Brazil
|
|
Posted: Mon Jul 05, 2004 12:37 pm |
|
|
PCM programmer,
In fact I use this command and it works on the application. The point is that sometimes it sends other character less to the output. I still didn't find any correlation to interrupt services.
My question intends to know if any buggy behaviour in printf() is know by people!
Thanks!
Marcus |
|
|
Guest
|
|
Posted: Mon Jul 05, 2004 7:57 pm |
|
|
the last one char will not be sent out if without the ... while(1); ... because CCS send PIC into sleep before the last one get out.
that's what happened to me years ago. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|