User manual

Table Of Contents
PICDEM
TM
Lab Development Board User’s Guide
DS41369A-page 26 © 2009 Microchip Technology Inc.
FIGURE 3-11: MAIN() SOFTWARE CONTROL LOOP FLOWCHART FOR
LAB 2
The Timing() delay routine is shown in Figure 3-12.
FIGURE 3-12: TIMING() DELAY ROUTINE FLOWCHART FOR LAB 2
Two variables are used delay_var1 and delay_var2. The delay_var2 is decre-
mented by 1 each time delay_var1 is decremented from 45571 to 0. These values
have been determined through trial and error using a test procedure detailed in the
“Timers: Timer0 Tutorial (Part 1)” (DS51682.pdf) included on the PICDEM™ Lab
Development Kit CD. This delay ties the up the processor for 1 second when using the
4 MHz internal oscillator.
The Initialize() configures the PORTC as follows:
•PORTC
- Set all bits in the PORTC register HIGH
- Configure all PORTC pins as digital outputs
main()
Initialize()
Do_Outputs()
Loop Forever
Timing()
TIMING()
Create two 8-bit variables:
delay_var1 = 45571
delay_var2 = 3
delay_var2 - 1 = 0
?
delay_var1 - 1 = 0
?
END
delay_var1 = 45571
YES
YES
NO
NO