PDA

View Full Version : interupt & Sleep Problem - HELP!!



Santana
- 22nd November 2004, 12:27
Hello People
I have a problem i have being trying toget my head round over the past 4 nights andhave come up with no solution so your help would be very much appreciated.

THE Design
=========
i am designing a data logger around the PIC18F452 as i would need 3 interupt sources

1. RB0 To wakeup the pic then take a reading
2. RB1 To wakeup the pic then take and take user setting( ie
Reading interval etc)
3. RB2 To be used as countdown timer using the 1Hz output
from a DS1307 RTC

THE Problem
=========

My PIC is asleep at least 99% of time , but RB2 interupt wakes it up when the 1hz pulse is applied
Is there another way i can count the pulses from the RTC without waking the PIC Or is there another way i can do this without using interupt on RB2?

The first two interupts works perfectly but i need to include a countdown timer so that i can check when 12 months has elasped


Please Help as i am slowly runningout of time

Best Regards

Ingvar
- 22nd November 2004, 14:14
You could use Timer1(or 3) configured as a counter and count the external 1Hz pulses. This way you could count pulses for up to six days without waking the pic. If you configure the counter with a prescaler 1:8 and preset it with 11536(65536-54000) you will count 8*54000=432000secs, that's exactly 5 days. When you have had this interrupt 73 times, exactly one year(365days) have passed.

/Ingvar

Santana
- 22nd November 2004, 22:45
Thanks Ingvar
Thats a good idea have you got any example on how tp set this up

Ingvar
- 23rd November 2004, 10:39
I haven't used this pic before but i can't see any major difficulties in setting it up. You already seem to be able to start and service interrups so i won't deal with that. Initialize the timer with ....

TMR1L = $10
TMR1H = $2D 'Start timer with 65536-54000=11536
T1CON = %00110111
' here you should input code to enable the interrupt

..... in your ISR you should reset the timer to $2D10 again, increment your fivedaycounter and reset the interruptflag.

Perhaps it would be easier if you posted your code and i'll make the changes that are needed.

/Ingvar