User manual

Table Of Contents
PICDEM
TM
Lab Development Board User’s Guide
DS41369A-page 42 © 2009 Microchip Technology Inc.
FIGURE 3-21: DELAY_5MS() SOFTWARE FLOWCHART FOR LAB 5
The RA2 pin voltage is then checked again. If still low, a push button press is indicated
and the direction bit variable is toggled. Otherwise, the direction value stays the
same.
The Decide() then uses the current direction value to determine which direction
to shift the contents of the LED_Output global variable. The Decide() software
flowchart is shown in Figure 3-22.
Delay_5mS()
T0IF = 1
(i.e., TMR0 overflow)
?
END
Clear the Timer0 overflow
flag (T0IF)
YES
NO
Preload the Timer0 result
register (TMR0) with 100
Timer0 configured in the Initialize() as fol-
lows:
Using the internal F
OSC/4 (4MHz/4) clock
source
TMR0 increments on low-to-high transition
of F
OSC/4
Prescaler configured for 1:32
Desired Timer0 Overflow Rate = (4/F
OSC) x number of counts to overflow x prescaler
5mS = 1μSeconds x (256 – TMR0 preload value) x 32
TMR0 preload value = 256 – 5mS = 99.75 rounded to 100
1μSeconds x 32
TMR0 preload value determined as follows: