I used PIC16f877A at proteus to do timer interrupt.
The code is pretty simple it has nothing to do rather than setting the timer1 registers , the while(1)
loop is empty , the timer setting is as below.
When I run it the frequency of RB0
is too low it's just 32 Hz while it should be much greater than that, I sat the clock frequency both on fuses and proteus to 16 MHz, pre and post scalers 1:1 , but it still extremely low, I believe the is something wrong with ISIS
it self , any ideas ?
main.c :
#include "config.h"
#include <stdint.h>
void main()
{
// -- [[ IO Configurations ]] --
TRISB0 = 0;
TMR1 = 0;
TMR1CS = 0;
T1CKPS0 = 0;
T1CKPS1 = 0;
TMR1ON = 1;
// -- [[ Interrupts Configurations ]] --
TMR1IE = 1; // Timer1 Interrupt Enable Bit
TMR1IF = 0; // Clear The Interrupt Flag Bit
PEIE = 1; // Peripherals Interrupts Enable Bit
GIE = 1; // Global Interrupts Enable Bit
while(1)
{
// Stay IDLE ,, Timer Interrupt Will Handle Everything For Us !
}
}
// Interrupt Service Routine - ISR
void __interrupt() ISR (void)
{
// Check The Flag Bit
if (TMR1IF)
{
RB0 = ~RB0;
TMR1IF=0;
}
}