0% found this document useful (0 votes)
190 views4 pages

CCS - View Topic - Alarm

The document discusses using alarms on a DS1306 real-time clock chip to trigger an interrupt on a PIC microcontroller after a certain amount of time. Someone is asking how to use the DS1306 alarm interrupts to trigger a buzzer on their PIC when a door sensor has been active for 30 seconds.

Uploaded by

api-3755810
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
190 views4 pages

CCS - View Topic - Alarm

The document discusses using alarms on a DS1306 real-time clock chip to trigger an interrupt on a PIC microcontroller after a certain amount of time. Someone is asking how to use the DS1306 alarm interrupts to trigger a buzzer on their PIC when a door sensor has been active for 30 seconds.

Uploaded by

api-3755810
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CCS :: View topic - Alarm http://ccsinfo.com/forum/viewtopic.php?t=22706&highlight=int0...

FAQ Forum Help Official CCS Support Search Register

Profile Log in to check your private messages Log in

Alarm

CCS Forum Index -> General CCS C Discussion

View previous topic :: View next topic

Author Message

Guest Alarm
Posted: Fri Apr 29, 2005 8:34 am

Hello,

i use a PIC18LF458 and a DS1306 RTC.

i wondered if someone could help me to understand the alarms on DS RTC, like DS1302 or
DS1306.

What i want to do is to put a buzzer on (on the pic) when for example a door sensor (on the PIC
as well) is true for 30 seconds.

Before it does nothing, after 30 seconds it puts the alarm on.

How can i count with this alarm using the interrupts pins of the DS ?

Thanks a lot.

ckielstra Posted: Fri Apr 29, 2005 9:09 am

Hi. Is this Global again? If yes, then try registering on this forum. It's for free and with your
Joined: 18 Mar 2004
Posts: 1332 name showing we know who we are dealing with. Posting as Guest is not very polite.
Location: The Netherlands

global Posted: Fri Apr 29, 2005 9:14 am

Sorry !
Joined: 01 Feb 2005
Posts: 63
I was not logged on ! Maybe i was disconnected !

Yes it is me =)

I need to have an interrupt on my PIC when the RTC matches with the alarm.
When the SENSOR_PIN is 1, i read the time and then add 1 minute to set the alarm one minute
later. When the alarm is on interrupt on the PIC, is switch on all the leds.

One minute later, the DS1306 sends an interruption on the PIC.


What is wrong ? My problem is to use if (!input(SENSOR_PIN)), to check if it is on during this

1 от 4 27.2.2007 г. 12:46
CCS :: View topic - Alarm http://ccsinfo.com/forum/viewtopic.php?t=22706&highlight=int0...

one minute ... and to set the alarm once when SENSOR_PIN is 1.

Here is my code :

Code:

#INT_EXT
ext_isr()
{
output_high(LED_1);
output_high(LED_2);
output_high(LED_3);
output_high(LED_4);
output_high(LED_5);
output_high(LED_6);
output_high(LED_7);
output_high(LED_8);
}

void main(void)
{

while(1)
{

if (!input(SENSOR_PIN))
{
rtc_get_time(heure, min, sec); // get the time

// initialize the alarm 1 minute later


write_ds1306(0x8F,0x01); // control register
write_ds1306(0x89,heure); // hour
write_ds1306(0x88,min + 0x01); // minute + 1 minute
write_ds1306(0x87,sec); // second
write_ds1306(0x8A,0x80); // day

enable_interrupts(global);
enable_interrupts(int_ext);
ext_int_edge(L_TO_H);
disable_interrupts(global);
disable_interrupts(int_ext);
}

Thanks for your help.

global Posted: Mon May 02, 2005 9:21 am

Any idea ?
Joined: 01 Feb 2005
Posts: 63
Thanks !

ckielstra Posted: Mon May 02, 2005 10:03 am

How did you define SENSOR_PIN?


Joined: 18 Mar 2004
Posts: 1332 Beware that you can't use a variable as parameter to the input() function.
Location: The Netherlands
A few more remarks:
1) I guess a sleep() call is missing after you enabled the interrupts?
2) You'll have to add a check for the minute count to be 59, or your code will fail. Also keep in
mind the 23:59 hour situation, last day of the month and last day of the year....

global Posted: Tue May 03, 2005 8:36 am

Hello ! You are right, i'll have to check that.


Joined: 01 Feb 2005
Posts: 63
I am looking for some code that will check time : If seconds, minutes and hours are over 59.

For example if i want to add 30 seconds when it is 23:59:59 ?

2 от 4 27.2.2007 г. 12:46
CCS :: View topic - Alarm http://ccsinfo.com/forum/viewtopic.php?t=22706&highlight=int0...

Does someones have any code for that ?

I don't mind of the day and date.

Thank you.

global Posted: Wed May 04, 2005 9:25 am

Joined: 01 Feb 2005


Posts: 63

Last edited by global on Fri May 06, 2005 6:37 am; edited 1 time in total

global Posted: Fri May 06, 2005 2:03 am

Hello,
Joined: 01 Feb 2005
Posts: 63
I did this which seems to work :

Code:
min = min + 1;

if(min > 59)


{
min = min - 60;
if (heure == 24) heure = 0;
else heure = heure + 1;
}

Is that ok ? Do you think i forget something ?

Last edited by global on Mon May 09, 2005 7:10 am; edited 1 time in total

ckielstra Posted: Sun May 08, 2005 11:46 am

For another example you can check this thread:


Joined: 18 Mar 2004
Posts: 1332 http://www.ccsinfo.com/forum/viewtopic.php?p=39216#39216
Location: The Netherlands

global Posted: Wed Oct 19, 2005 6:21 am

Hello,
Joined: 01 Feb 2005
Posts: 63
i need to use the DS1306 again, and i thought i found the way to make it work but it seems that
the interrupt generated by the DS1306 is not seen by the PIC. I am sure that it is generated
because the alamr is well configured and the registers are correct when it is generated.

I checked if it was a hardware problem but nothing ...

I checked the register that shows if the alarm works on the DS1306, it is fine.
the trouble is i can't make it work properly with the #INT_EXT interruption.

What do you mean for this suggestion :

Quote:
1) I guess a sleep() call is missing after you enabled the interrupts?

3 от 4 27.2.2007 г. 12:46
CCS :: View topic - Alarm http://ccsinfo.com/forum/viewtopic.php?t=22706&highlight=int0...

I wrote it this way :

Code:
enable_interrupts(INT_RTCC);
enable_interrupts(INT_TIMER1);
//enable_interrupts(INT_TIMER2);
//enable_interrupts(INT_TIMER3);

enable_interrupts(GLOBAL);
enable_interrupts(INT_EXT); // interruptions alarme
ext_int_edge(L_TO_H);

and the interrupt is just like this, for the moment :

Code:
#INT_EXT
ext_isr()
{
output_high(LED_RED);
}

Any suggestion ?

Many thanks.

PCM programmer Posted: Wed Oct 19, 2005 1:24 pm

Quote:
Joined: 06 Sep 2003
Posts: 6760 it seems that the interrupt generated by the DS1306 is not seen by the PIC
I checked if it was a hardware problem but nothing ...

You didn't say what interrupt pin you're using on the DS1306.
The \INT0 pin on the DS1306 is open-drain and requires a pull-up
resistor. Also, it's active low.

global Posted: Thu Oct 20, 2005 7:52 am

Hello,
Joined: 01 Feb 2005
Posts: 63
many thanks, you are correct but i already added the pull-up :p

It is the INT0.

I putted ext_int_edge(H_TO_L);

I think it was a hardware problem, i just soldered the PIC pin on B0 and it works !

Thanks again.

Best regards.

Display posts from previous: All Posts Oldest First Go

All times are GMT - 6 Hours


CCS Forum Index -> General CCS C Discussion

Page 1 of 1

Jump to: General CCS C Discussion Go

You can post new topics in this forum


You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group

4 от 4 27.2.2007 г. 12:46

You might also like