PDA

View Full Version : hexadecimal



thibaud
- 9th June 2006, 15:37
Maybe a suppied question

I want to connect a zigbee via serial interface to a PIC 18F877.

want is the command to present something in HEX!!

I always have to work with binairy to make it workable:

a = %10101000 what is the hex command


thanks

SteveB
- 9th June 2006, 16:00
4.8. Numeric Constants (rtfm)

PBP allows numeric constants to be defined in the three bases: decimal, binary and hexadecimal. Binary values are defined using the prefix '%' and hexadecimal values using the prefix '$'. Decimal values are the default and require no prefix.

100 ' Decimal value 100
%100 ' Binary value for decimal 4
$100 ' Hexadecimal value for decimal 256

thibaud
- 9th June 2006, 16:22
Yes Steve but,

I tried in the code to put

b = $AE

and it gives a compile error ????
How should it be:

thibaud
- 9th June 2006, 16:28
my zigbee expects to see the following:

byte 1: 0x7E

how to configure this in my code ????

DynamoBen
- 9th June 2006, 16:45
There really isn't anything to configure. All of the below options will give you the same results. 0x7E is just the hex value 7E or Decimal 126. You can use the ASCII chart in the back of the manual. Also I find the following link to MELabs helpfull. http://www.melabs.com/resources/convert.htm

Variables
Byte1 var $7E, Byte1 var 126, Byte1 var "~", Byte1 var %01111110

Constants:
Byte1 con $7E, Byte1 con 126, Byte1 con "~", Byte1 con %01111110

SteveB
- 9th June 2006, 16:56
I tried in the code to put


b = $AE

and it gives a compile error ????


Exactly what error does it give you? That will help a lot in determining the actually error. It certianly ins't just because you used:


b = $AE
Instead of

b = 174
or

b = %10101110

Steve

mister_e
- 9th June 2006, 17:01
may i guess that b wasn't previoulsy defined as a byte or word and it returned a Syntax error?

thibaud
- 9th June 2006, 17:34
b = $7E 'line 15

debug $7E


I get a ERROR Line 15: Syntax error. (API.pbp)

Bruce
- 9th June 2006, 18:16
B Var Byte

B = $7e

Debug Hex2 B

thibaud
- 9th June 2006, 19:38
thanks it works!

where can I find more information about the Hex2

I didn't find it in the www.melabs.com (pro basic documentation)

Bruce
- 9th June 2006, 19:44
Look in your PBP manual under DEBUG or SEROUT2 for data modifiers each
command supports.

They don't go into great details on using them, but they're there.