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

Sending int values via RS232

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







Sending int values via RS232
PostPosted: Wed Dec 08, 2004 1:09 am     Reply with quote

Is there a way to send int value via rs232 using usart. I want to debug my program using hyperterminal so it would be nice to see numeric values. Since putc only sends as character, is there any trick to send the numeric value.
Thanks in advance.
RossJ



Joined: 25 Aug 2004
Posts: 66

View user's profile Send private message

PostPosted: Wed Dec 08, 2004 1:35 am     Reply with quote

You should probably use printf(). For example...

Code:
int8 x;
printf("%U", x);


will send the value of x (as an unsigned int) in ascii suitable for viewing in a terminal program.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

Step #1: Replace Hyperterminal
PostPosted: Wed Dec 08, 2004 8:12 am     Reply with quote

Printf is the easy way, as it turns the int into an ASCII string for display on an ASCII terminal. But printf has significant overhead. There is a little less overhead if you have printf produce hex instead of decimal:
Code:
int8 x;
printf("%X",x);

But your real problem is Hyperterminal. Hyperterminal is really pathetic for programming use. It has bugs and lots of wierd behavior even with the limited things it does. Hyperterminal for OS/2 was good but it fell apart when it was ported to Windows. There are lots of better programs such as the siow.exe program than comes with CCS products. My favorite is terminal.exe by Br@y++ http://bray.velenje.cx/avr/terminal/ . Terminal displays not just the ASCII but also the binary, decimal, and hex of the incomming characters. With this you can just putc(x); and read the value off your PC screen with minimal overhead for the PIC.
_________________
The search for better is endless. Instead simply find very good and get the job done.
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