I want to use the internal oscillator in PIC16F616 in 8 MHz configuration and have the I/O function on RA4 and RA5. I've read through the datasheet, and I cannot find what I am doing wrong.
As far as I understand from the below information, TMR0 should increment every 500 ns, and it should create an interrupt when it overflows from "0xFF" to "0x00".
However, RA4 pin toggles about every 20 us.
From the datasheet:
5.1.1
8-BIT TIMER MODE
When used as a timer, the Timer0 module will increment every instruction cycle (without prescaler).
Timer mode is selected by clearing the T0CS bit of the OPTION register to ‘0’.
Also;
Note: The value written to the TMR0 register can be adjusted, in order to account for the two instruction cycle delay when TMR0 is written.

Here is my code, my compiler is MPLAB XC8. :
#include <xc.h>
__CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_ON & MCLRE_OFF & CP_OFF & IOSCFS_8MHZ & BOREN_ON);
void interrupt myInterrupt(void)
{
if (T0IE && T0IF)
{
RA4 = ~RA4;
TMR0 = 254;
T0IF = 0;
}
}
void main()
{
TRISA = 0;
ANSEL = 0;
PSA = 1; // Prescaler Assignment bit : 1 = Prescaler is assigned to the WDT, 0 = Prescaler is assigned to the Timer0 module
T0CS = 0; // T0CS: TMR0 Clock Source Select bit : 0 = Internal instruction cycle clock (FOSC/4), 1 = Transition on T0CKI pin
T0IE = 1; //T0IE: Timer0 Overflow Interrupt Enable bit
GIE = 1; //GIE: Global Interrupt Enable bit
while (1);
}
Multiple attributes can be selected by ANDing them together.– abdullah kahraman Apr 19 '12 at 5:29