User manual

Table Of Contents
General Purpose Input/Output Labs
© 2009 Microchip Technology Inc. DS41369A-page 49
FIGURE 3-23: MAIN() SOFTWARE CONTROL LOOP FLOWCHART FOR
GPIO LAB 6
Note the removal of the Get_Inputs() from the previous lab. This code will now be
handled by an Interrupt Service Routine (ISR) whenever the push button is pressed.
The PB_PressISR() flowchart is shown in Figure 3-24.
FIGURE 3-24: PB_PRESSISR() FOR LAB 6 SHOWING SWITCH DEBOUNCE
main()
Initialize()
Do_Outputs()
Loop Forever
Timing()
Decide()
Global Variables:
8-bit variable LED_Output will be used to light
the LEDs connected to PORTC
1-bit variable direction used to determine the
direction of the sequential LED flashing
0 = shift PORTC bits right-to-left
1 = shift PORTC bits left-to-right
PB_PressISR()
INTE and INTF
bits set
?
RETURN
NO
Clear INTF flag
YES
RA2 pin = 0
?
direction = direction
Delay for 5mS
YES
RA2 pin = 0
?
Tog gle direction
YES
NO
NO