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

Problems with Printf

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







Problems with Printf
PostPosted: Tue Feb 04, 2003 6:03 am     Reply with quote

I want to printf an int16 variable on rs232

In this Code i shift my Values i read from PIN A0 in the int16 "code"
and i want to printf this int16
how can i make this ??

while(i<14)
{
while(get_timer0() >= abtast)
{
newbit=input(PIN_A0);

if(newbit == 0)
{
code=code|0x01;
code<<=1; }
if(newbit == 1)
{
code=code|0x01;
code<<=1; }
abtast=abtast+14;
i++;
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 11263
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Problems with Printf
PostPosted: Wed Feb 05, 2003 2:38 pm     Reply with quote

<font face="Courier New" size=-1>:=I want to printf an int16 variable on rs232
:=
-------------------------------------------------
Chris,
If you just want to print a 16 bit value with printf,
you should do this:

main()
{
int16 code;

code = 0x55AA;

printf("code = \%lx \n\r", code);


while(1); // Prevent PIC from going to sleep (Very important)

// Extra notes on the "while(1);" line above:
// CCS puts a hidden sleep instruction after the end of main().
// The while(1) statement prevents the program from reaching
// that instruction. If it did reach that instruction, then
// the last 2 characters of your printf statement (the "AA")
// would not be displayed. So it's very important to put
// that statement above the end of main().

}


On your terminal window, you will see this:

code = 55AA

The number is displayed in hexadecimal notation.
This is caused by using "lx", which means to display
a 16-bit number in hex. To display it in unsigned
decimal format, use "lu" instead.</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11311
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