Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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?
 

motion

New Member
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.
 

RonDumas

New Member
Thanks for the help Motion,
I get it. :oops: 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.

Latest threads

Top