User manual

Table Of Contents
PICDEM
TM
Lab Development Board User’s Guide
DS41369A-page 34 © 2009 Microchip Technology Inc.
3.3.7 Lab 4: Rotate LEDs
3.3.7.1 OVERVIEW
This lab shifts a high bit in the PORTC register from right-to-left each time through the
software loop sequentially lighting the LEDs connected to the PORTC pins in 1 second
intervals as dictated by the Timing(). This lab adds some new functional blocks to
the main() software control loop as shown in Figure 3-15.
FIGURE 3-15: MAIN() SOFTWARE CONTROL LOOP FLOWCHART FOR
LAB 4
The addition of an 8-bit global variable (can be manipulated by any function) called
LED_Output is used. This variable will be acted upon by the new Decide() by shift-
ing a high bit in LED_Output from right-to-left each time this function is called. The
flowchart for the Decide() is shown in Figure 3-16.
FIGURE 3-16: DECIDE() FLOWCHART FOR LAB 4
main()
Initialize()
Do_Outputs()
Loop Forever
Timing()
Decide()
Global Variables:
8-bit LED_Output
Decide()
LED_Output = 0b10000000
or
LED_Output = 0b00000000
?
END
Shift contents of LED_Output
variable left by 1 bit position
YES
NO
LED_Output = 0b00000001
LED_Output variable initialize to 0b00000001
in Initialize()