View previous topic :: View next topic |
Author |
Message |
imad
Joined: 03 Apr 2006 Posts: 1
|
int to char |
Posted: Mon Apr 10, 2006 12:30 am |
|
|
Hello,
i am trying to send an integer value over the RS232 using the function putc(), which have a parameter char,
does anybody have an idea?
thanx |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 10, 2006 1:00 am |
|
|
If you want to send a binary number which is larger than a byte,
such as an int16 for int32 value, then can use the CCS make8()
function to extract the individual bytes and send them with putc().
Look in the manual for information on using make8().
If you want to see the number that you're sending, in a terminal
window on your PC (such as Hyperterminal), then you need to
send the value as ASCII digits. You can use printf() for that.
Again, see the CCS manual for more information on printf(). |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
Bits is bits |
Posted: Mon Apr 10, 2006 6:46 am |
|
|
A standard CCS int is 8 bits so it fits nicely in a char. You can putc() an 8 bit int with no problems. But formally you could cast it to a char first. Casting would improve readability and there would be no code overhead. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
|