Please note that the "TimeDelay.h" inside the Microchip Application library has a bit of a problem. The delays are a bit off in a few more miliseconds which could affect the program flow if timing is used. It could be my breadboarded setup, or my crystal (it's in 10MHz instead of 8) or both. I will contact Microchip for further information.
Here's a temporary workaround for it, using a Timer. Add this function inside your code.
- CODE: SELECT_ALL_CODE
void delay_ms(unsigned int count)
{
T1CON = 0x8030; // turn on timer, prescaler to 256
while(count--)
{
TMR1 = 0;
while(TMR1 < 0x4e);
}
T1CONbits.ON = 0;
}
(Setup information: 10MHz crystal PLL to 40MHz, Peripheral bus = 20MHz, prescaler 256)
Just put the desired no. of miliseconds inside the function.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool