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.

Power down mode problem with timer 0 interrupt...

Status
Not open for further replies.

seemanta

Member level 4
Joined
Jun 10, 2006
Messages
71
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,288
Activity points
1,968
Power down mode problem with timer 0 int - solution found!

Hi,
I have observed that after going to sleep and waking up, my timer 0 interrupt handler does not get called.

My problem is this:

My micro receives an external interrupt every second from a real time clock. This external interrupt is tied to /INT0 of the micro.

I need to light up an LED for 10 seconds(visual alarm). I calculated how many times timer 0 would overflow in 10 seconds. Let us call this count 'n'. Then in my timer 0 ISR, I keep a count how many times the ISR was called. When this number matches 'n' I know that 10 seconds have elapsed and then I shut the LED down.

The problem I am facing is that if I go to power down mode between the RTC interrupts, my LED keeps on blinking and never stops. Basically the count 'n' is never reached.

However, if I choose to go to idle mode instead of power down mode, everything works and my LED does not light up after 10 seconds.

Somehow I believe that this is due to the oscillator stopping in power down mode and not stopping in idle mode. But I am not able to figure out the exact connection.

Can anyone please suggest what is happening here?


Thanks in advance!

regards,
Seemanta

Added after 2 hours 13 minutes:

I got the cause of this problem! Just wanted to share with the rest of the edaboard'ians.

Well, since the oscillator freezes between each interrupt, the TH0 and TL0 registers also freeze during the time the micro remains in power down.

That is why the whole thing effectively slows down, since to reach the count 'n'the micro has to spend more time than it would have spent with the oscillator running all the time.

I guess, this is the first time someone has posted the problem and the solution as well!

Hope this will help anyone in the future facing the same problem as
I too faced!

regards,
Seemanta
 

Hi,

Thanks a lot for sharing!

You can implement the counting of variable n in your RTC interrupt routine and switch of your LED if the count equals 10 since your RTC interrupts the controller every 1 second and your required delay is 10 seconds
 

Yes, Rajeshkumar123,
That idea also came to my mind.

However, with that some extra code would always run in my ISR and I wanted to avoid that and keep my ISR as small and fast as possible.

I thought I would simply start the timer and forget about it until the interrupt for 10 seconds comes in.

But looks like now I might have to revise my opinion. With power down code, the timer register overflows every 9 seconds, not 10 seconds. I would now have to check against magic numbers in the TH0 and TL0 registers to get the exact 10 seconds delay!


regards,
Seemanta
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top