CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

printf help

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








printf help
PostPosted: Mon Mar 15, 2004 8:04 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Mar 16, 2004 2:02 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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