View previous topic :: View next topic |
Author |
Message |
Dune Guest
|
questions about CCS variables |
Posted: Sat Nov 01, 2008 2:13 am |
|
|
Hi all,
I´ll really appreciate than somebody help with this questions:
1-what´s the difference between int8 and byte.
2-is there any built in function that convert to hex form (in fact, I´ll use a procedure that deals with hex, however my variables are bytes, what should I do ?)
3-I sent an integer using bputc() and receive it with bputc(), what is its received type?
Code: |
r=bgetc() // integer ??
|
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sat Nov 01, 2008 2:45 am |
|
|
BYTE is defined as int alias (which by default means int8) in CCS C header files. In case insensitive mode, you can also write byte. In other words, int8 and byte are identical.
I don't understand what you mean with hex form. Hex, in my understanding is one of several formats that can be used to print (read and write) numbers. You usually generate hex representation by printf() respectively sprintf() function. putc() simply sends one character to the interface. bputc() acually isn't a standard function rather than a function name used in a particular CCS programming example.
Sometimes two-digit numbers are BCD-coded to a byte, e.g. when interfacing real time clocks. In this case, the hex printout of the byte is identical to the coded number, e.g. 0x11 means 11th hour. |
|
|
Dune Guest
|
|
Posted: Sat Nov 01, 2008 6:36 am |
|
|
hi FvM,
thank you for answers,
to clarify my second question:
suppose this code:
are
Code: | if (a==0x01)
{ //do somthing} |
and
Code: |
if (a==1)
{ //do somthing} |
the same ? |
|
|
dbotkin
Joined: 08 Sep 2003 Posts: 197 Location: Omaha NE USA
|
|
Posted: Sat Nov 01, 2008 7:10 am |
|
|
Yes, exactly the same. So is
Code: | if (a==0b00000001)
{ //do somthing} |
and, I think,
Code: | if (a=='\001')
{ //do somthing} |
though I've never tried using octal. |
|
|
|