I want to toggle a pin as fast as possible using TMR0.
I use this code (kind of pseudocode)
What is the frequency I get? Well, due to 2 instruction delay if you write to TMR0, I should be getting an interrupt every third instruction cycle. With the pic (16f676) running on internal 4Mhz oscillator, 4 / 4 = 1Mhz is the clock for TMR0. Because it interrupts every third instruction cycle, it should give me a frequency of around 1/3 Mhz.
Am I correct? But Proteus ISIS simulation shows its just around 20Khz. How do you calculate the max possible frequency?
I use this code (kind of pseudocode)
Code:
interrupt_isr()
{
if(T0IF){
togglepin();
TMR0 = 255;
T0IF = 0;
}
}
What is the frequency I get? Well, due to 2 instruction delay if you write to TMR0, I should be getting an interrupt every third instruction cycle. With the pic (16f676) running on internal 4Mhz oscillator, 4 / 4 = 1Mhz is the clock for TMR0. Because it interrupts every third instruction cycle, it should give me a frequency of around 1/3 Mhz.
Am I correct? But Proteus ISIS simulation shows its just around 20Khz. How do you calculate the max possible frequency?