Interrupt Usage

Status
Not open for further replies.

RonDumas

New Member
With a 16f876 running a 4Mh external osc. I would like to use the Tmr0 overflow interrupt to trigger a data transmit to the usart.
Could someone better explain the calculations to determin the timing.
For instance, I believe the timer will overflow every 255 clock cycles.
If I use the 1:8 TMRO rate does this mean 255 * 8 = 2040 cycles?
Or are these numbers to be divided by 4 ? Multiplied by 4 ?
I'm using the internal osc to drive Tmr0.
What is the difference between clock cycles and instruction cycles?
Is it one instruction cycle to every 4 clock cycles?
Am I way off base?
 
1. First of all, TMR0 generates an interrupt every 256 counts.
2. If the prescale is 1:8, then the each count increments every 8 instruction cycles and so each interrupt occurs every 8*256 cycles=2048.
3. The instruction cycle is 1/4 the oscillator frequency. E.G. for the 4Mhz crystal, the instruction frequency is 1Mhz.
 
Thanks for the help Motion,
I get it. Newbie error.The timer is full at 255 and overflows at 256.

If I understand what you're telling me then if I use the 1:256 prescaler I will cause an interrupt about 15 times per second, or am I missing something again?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…