Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Timer interrupt- what happens if the routine takes more

Status
Not open for further replies.

devendra_devgupta

Member level 3
Joined
Apr 8, 2007
Messages
54
Helped
3
Reputation
6
Reaction score
0
Trophy points
1,286
Activity points
1,632
Timer interrupt

Hello friends

I am using 10ms timer interrupt, Can any body tell me what happens if the routine written in the timer interrupt takes more than 10ms, system crash, interrupt within interrupt, or interrupt disabled or nothing, i m using LPC2366

plz help me

Thax in advance
 

Re: Timer interrupt

During an interrupt, other interrupts of equal or less priority are blocked.
If the interrupt is set by a timer overflow and your interrupt routine takes longer than the timer period, the interrupt flag will be set and the interrupt will be pending.
In the interrupt routine, it depends when you clear the interrupt flag.
If you clear it at the beginning of the interrupt, it will be set again by the timer, the interrupt will finish and the pending interrupt will immediatly execute.
if you clear it at the end of the interrupt routine, you will clear the pending interrupt but you will loose your 10mS timing interval.

The golden rule is that interrupts should be short and sweet.
Unless you are doing a psuedo dual tasking program.

That should make things as clear as mud!
 
Timer interrupt

Thanx and sorry for late reply

Added after 5 minutes:

but tell me one thing that if i clear the interrupt at the end of interrupt routine don't you think that the timer counter will also get reset and i will lost the time during which i am in the ISR say if i am executing some thing in ISR for 9 ms in a 10ms interrupt than the next interrupt will occur after 19ms (lost 9ms + next 10ms) instead of 1 ms


please reply
 

Re: Timer interrupt

Clearing the interrupt flag does not reset the timer.
The timer free runs, overflows and carries on from 0.
Unless you change it yourself.

So in your example. If your interrupt routine does not change the timer and you take 9mS, the next interrupt will occur 1mS after exiting the interrupt.

A good way to check interrupt frequency, is to toggle a spare I/O line when entering the interrupt. Put a scope on the line and you can see and measure the interrupt frequency.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top