So I downloaded the mikroElektronika Timer Calculator application from libstock. On the first project I used it for I was using a PIC16F887 running at 8Mhz, the timer I set-up was a 100ms timer and the results were great.
I've not moved onto my EasyPICv7 which has a PIC18F45K22 running at 32Mhz, I've set-up the application for the PIC18, Timer0, 32Mhz, 100ms, it does display a dialog warning me of a small difference in the requested 100ms period to the actual timer accuracy, but this is in the ns, difference error was 0.000249999%. However when I use the code produce the actual timing seems way out and nothing like 100ms.
This is the code I got from the application:
Code: Select all
void InitTimer0(){
T0CON = 0x83;
TMR0H = 0x3C;
TMR0L = 0xAF;
GIE_bit = 1;
TMR0IE_bit = 1;
}
void Interrupt(){
if (TMR0IF_bit){
TMR0IF_bit = 0;
TMR0H = 0x3C;
TMR0L = 0xAF;
//Enter your code here
}
}