Introduction to Microcontroller Programming
About PICmicro Chips
Clocking Your PICmicro Devices E-Blocks Flowcode Step By Step
PICmicro Projects
Labs |
Working in HexIf you are working through this as an experienced programmer you will now have a question: "I wonder if Flowcode supports Hexadecimal numbers?" If you are already feeling overwhelmed then skip this section and come back to it later. The answer is yes. Hexadecimal, 'Hex' for short, is a more convenient form (for humans) of representing numbers than binary. A binary digit in a number varies between 0 and 1. A decimal digit varies between 0 and 10. A hex digit has 16 possible states. Clearly this is a problem as we have only the digits 0 to 9. To get round this we use the letters A to F to represent the additional 6 digits required. The following table shows the equivalent numbers in decimal, binary and hex:
Note that we have shown the binary number with 8 digits. This is a handy convention as computers - and our PICmicro chips - store information in groups of 8 bits. A single memory cell inside a PICmicro device varies between 00000000 and 11111111. In decimal this range is 0 to 255. The equivalent in Hex is 0 to FF. Hex in FlowcodeYou can put Hex in Flowcode by preceeding it by the letters '0x' in any of the dialogue boxes. For example: This is the equivalent to placing the number 11110000 onto port B. In other words it will place a logic 1 (normally 5 volts) onto the top 4 output pins, and a logic 0 (0 volts) onto the bottom 4 pins. |