|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
printf help |
Posted: Mon Mar 15, 2004 8:04 pm |
|
|
Hello,
I have a trivial question regarding my application. I am sending 18 int8 variables through the serial port using the printf statement:
printf("%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X", Tx1_L,Tx1_H,Rx1_L,Rx1_H,Tx2_L,Tx2_H,Rx2_L,
Rx2_H,CH0_L,CH0_H, CH1_L,CH1_H,CH2_L,CH2_H,CH4_L,CH4_H,CH5_L,
CH5_H,CH6_L,CH6_H); (each variable is int8)
If i see the result using hyperterminal, I see the right data, 18 bytes received. I sent the programmed PIC to a customer and he reported looking at approx 38 bytes using an digital oscilloscope. Is this possible? because even if we add the start and stop bit, we still are far from 38 bytes.
Also long back I was suggested that I use %02X instead of %2X for outputting data to avoid losing leading zero's in the output. But I did not see any such thing when I observe the o/p in the hyperterminal. Is %02X really needed? Please suggest.
Thanks.
mach |
|
|
wedilo
Joined: 16 Sep 2003 Posts: 71 Location: Moers, Germany
|
|
Posted: Tue Mar 16, 2004 2:02 am |
|
|
Hello Gast,
I think your customer is right.
For Example:
Code: | int nTemp = 0xC0;
printf("%2X", nTemp);
|
In this case the uart will send 1 byte for the 'C' and 1 byte for the '0'. Because you send two chars.
Code: | long lTemp = 0xC0FF;
printf("%4LX", lTemp);
|
In this case the uart will send 4 bytes
So you can see 18 values (int) needs 36 bytes. But I can't explain why your customer counts 38 bytes.
Is there any carridge return or line feed or other control sequence ??
Hope that help you
73 Sven |
|
|
|
|
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
|