User manual

Table Of Contents
PICDEM
TM
Lab Development Board User’s Guide
DS41369A-page 28 © 2009 Microchip Technology Inc.
EXAMPLE 3-5: DO_OUTPUT() CODE FOR LAB 2
3. Copy/paste the code in Example 3-6 into the Timing() section labeled:
//ADD TIMING CODE HERE
EXAMPLE 3-6: TIMING() FOR LAB 2
4. Copy/paste the code in Example 3-7 over the main() code from the previous lab
to incorporate the Timing().
EXAMPLE 3-7: MAIN() CODE FOR LAB 2
Compile the project. There should be no errors.
3.3.5.3 TESTING THE APPLICATION
Program the PIC16F690. The LEDs connected to the individual PORTC pins should
now all flash on/off in 1 second intervals.
The solution for this project is located in the
C:\PICDEM_Lab\GPIO_Labs\GPIO_Lab2\solution directory.
RC0 ^= 1;//XOR current RC0 value with 1
RC1 ^= 1;//XOR current RC1 value with 1
RC2 ^= 1;//XOR current RC2 value with 1
RC3 ^= 1;//XOR current RC3 value with 1
RC4 ^= 1;//XOR current RC4 value with 1
RC5 ^= 1;//XOR current RC5 value with 1
RC6 ^= 1;//XOR current RC6 value with 1
RC7 ^= 1;//XOR current RC7 value with 1
//--------DELAY 1second-------------------------
//Variable used in delay loop
unsigned int delay_var1 = 45571;
unsigned char delay_var2 = 3;
//Nested while loops to implement a 1 second delay
//Decrement delay_var2, if 0 jump out of loop
while(--delay_var2)
{
//Decrement delay_var1, if 0 jump out of loop
while(--delay_var1);
}
Initialize(); //Initialize the relevant registers
while(1)
{
Do_Outputs(); //Perform any outputs
Timing();//Sets execution rate of the
//Software Control Loop
}