Introduction to Microcontroller Programming
About PICmicro Chips
Clocking Your PICmicro Devices E-Blocks Flowcode Step By Step
PICmicro Projects
Labs |
Set up the Left Output
A word of explanation! - This set up outputs the number 255 from the output port. Normally, this would light up all the LED's connected to the port. By clicking the 'Use Masking' box, and selecting bit 0, we make all the LED's inactive apart from LED 0, the right hand one. This is one way to turn on only bit 0. Here are two alternative ways of doing the same thing!
Outputting the value '1' (= 0000 0001 in binary) switches on only the LED attached to bit 0. But this command will also force all the other pins on Port B to logic 0. The third option outputs value '255' (= 1111 1111 in binary,) and it puts all pins at logic 1. This should give you a hint of what the advantage of masking is: it allows you to alter the status of the lines on a port individually. Masking allows you to make a pin high or low without altering the status of the other pins on the same port.
Outputting value '0' turns off all LED's connected to Port B.
|