
Dear Larry,
I am rather curious about this 0x84 in my code. Can you explain to me the significance of 0x84?
Hector G.
Well Hector, the 0x84 that you are seeing is a hexadecimal number. We use this system because it makes it easier to read the bits at a glance. We found that it helps to speed up the development process. Take a look at this table:
| Hex | Binary |
| 0 | 0000 |
| 1 | 0001 |
| 2 | 0010 |
| 3 | 0011 |
| 4 | 0100 |
| 5 | 0101 |
| 6 | 0110 |
| 7 | 0111 |
| 8 | 1000 |
| 9 | 1001 |
| A | 1010 |
| B | 1011 |
| C | 1100 |
| D | 1101 |
| E | 1110 |
| F | 1111 |
Each hexadecimal digit is 4 bits and two digits gives us a full byte.
Some examples:
0x00 = 0000 0000
0x40 = 0100 0000
0xAC = 1010 1100
ox84 = 1000 0100
Being able to see the value of each bit is especially useful when we want to look at a register.
For example look at the following statement:
WrPortI(SPCR, &SPCRShadow, 0x84)
It writes "1000 0100" to the bits of the SPCR register.
Looking at the Easy Reference Poster and finding SPCR on the right side under SLAVE PORT we can decode what the bits are doing.
Bit 7 - 0 (program fetch as a function of smode pins)
Bit 6 - 0 (ignored for Write)
Bit 5 - 1 (ignored for Write)
Bit 4 - 0 (always zero)
Bit 3 - 0 (Disable slave port - port is byte-wide input)
Bit 2 - 0 (Disable slave port - port is byte-wide input)
Bit 1 - 0 (Priority 2 interrupt)
Bit 0 - 1 (Priority 2 interrupt)
I hope that explains why hexadecimal is so useful. Good luck with your application!
- Larry C.
Larry Cicchinelli is Rabbit Semiconductor’s Technical Support Manager. He has 30 years of embedded experience, and is considered one of the foremost authorities on Rabbit products. Larry and his staff offer comprehensive technical support to Rabbit customers.
Submit your questions for Larry via email at
AskLarry@rabbit.com
Read more Ask Larry Answers