User manual

Table Of Contents
General Purpose Input/Output Labs
© 2009 Microchip Technology Inc. DS41369A-page 43
FIGURE 3-22: DECIDE() SOFTWARE FLOWCHART FOR LAB 5
Similar to the previous lab, Decide() checks the LED_Output variable value before
executing the shift to ensure that the variable is not all 0’s or that the Most Significant
bit, for a left shift, or Least Significant bit, for a right shift, are not ‘1’, indicating that the
shift that follows will fill the LED_Output variable with 0’s.
The Do_Outputs() simply assigns the contents of the LED_Output variable to the
PORTC register lighting the connected LEDs accordingly.
3.4.4.3 PROCEDURE
Using the firmware developed in the previous lab, make the following changes:
Copy/paste the code in Example 3-16 into the top of the firmware source template under the
section marked:
//--------------------DATA MEMORY----------------------
EXAMPLE 3-16: VARIABLE DECLARATIONS FOR LAB 5
Decide()
direction = 0
?
END
LED_Output =
0b00000001
YES
NO
Shift contents of
LED_Output left
by 1 bit position
NO
YES
LED_Output = 0b10000000
or
LED_Output = 0b00000000
?
YES
NO
LED_Output = 0b10000000
Shift contents of
LED_Output right
by 1 bit position
LED_Output = 0b00000001
or
LED_Output = 0b00000000
?
unsigned char LED_Output;//Variable used to set/clear PORTC bits
bit direction;//Variable to select direction of shifting LEDs