User manual

Table Of Contents
PICDEM
TM
Lab Development Board User’s Guide
DS41369A-page 32 © 2009 Microchip Technology Inc.
The Initialize() now configures the PIC16F690 peripherals as follows:
•PORTC
- Set all bits in PORTC high
- Make all PORTC pins digital output
•Timer0
- Use the internal instruction clock (F
OSC/4) as the TMR0 register clock source
- Increment TMR0 register on low-to-high transition of F
OSC/4
- Assign the prescaler to Timer0 and configure to increment on every 256th
transition of F
OSC/4
3.3.6.3 PROCEDURE
Using the firmware developed in the previous lab, make the following changes:
1. Copy/paste the code in Example 3-8 at the top of the main firmware source file
under the heading labeled:
/**SUPPORT ROUTINES**********************************/
EXAMPLE 3-8: DELAY_1S() CODE FOR LAB 3
2. Copy/paste the code in Example 3-9 into the Initialize() over the code from
the previous lab.
/*---------------------------------------------------------
Subroutine: Delay_1S
Parameters: none
Returns:nothing
Synopsis:Creates a 1S delay when called
---------------------------------------------------------*/
void Delay_1S(void)
{
//Create an 8-bit variable called counter
//and initialize it to 0
unsigned char counter = 0;
while(counter <= 15)
{
//Make sure the T0IF is cleared
T0IF = 0;
//Clear the TMR0 register
TMR0 = 0;
//Sit here and wait for Timer0 to overflow
while (T0IF == 0);
++counter;
}
}