CCS :: View topic - Alarm
FAQ
http://ccsinfo.com/forum/viewtopic.php?t=22706&highlight=int0...
Forum Help Profile
Official CCS Support
Search
Log in to check your private messages
Register Log in
Alarm CCS Forum Index -> General CCS C Discussion View previous topic :: View next topic Author Guest
Message 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
Joined: 18 Mar 2004 Posts: 1332 Location: The Netherlands
global
Joined: 01 Feb 2005 Posts: 63
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 name showing we know who we are dealing with. Posting as Guest is not very polite.
Posted: Fri Apr 29, 2005 9:14 am
Sorry ! 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
Joined: 01 Feb 2005 Posts: 63
Posted: Mon May 02, 2005 9:21 am
Any idea ? Thanks !
ckielstra
Joined: 18 Mar 2004 Posts: 1332 Location: The Netherlands
Posted: Mon May 02, 2005 10:03 am
How did you define SENSOR_PIN? Beware that you can't use a variable as parameter to the input() function. 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
Joined: 01 Feb 2005 Posts: 63
Posted: Tue May 03, 2005 8:36 am
Hello ! You are right, i'll have to check that. 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
Joined: 01 Feb 2005 Posts: 63
Posted: Fri May 06, 2005 2:03 am
Hello, 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
Joined: 18 Mar 2004 Posts: 1332 Location: The Netherlands
global
Joined: 01 Feb 2005 Posts: 63
Posted: Sun May 08, 2005 11:46 am
For another example you can check this thread: http://www.ccsinfo.com/forum/viewtopic.php?p=39216#39216
Posted: Wed Oct 19, 2005 6:21 am
Hello, 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
Joined: 06 Sep 2003 Posts: 6760
Posted: Wed Oct 19, 2005 1:24 pm
Quote: 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
Joined: 01 Feb 2005 Posts: 63
Posted: Thu Oct 20, 2005 7:52 am
Hello, 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
CCS Forum Index -> General CCS C Discussion
Go All times are GMT - 6 Hours
Page 1 of 1 Jump to: General CCS C Discussion You can post new topics You can reply to topics You cannot edit your posts You cannot delete your posts You cannot vote in polls
Go in in in in in
this this this this this
forum forum forum forum forum
Powered by phpBB © 2001, 2005 phpBB Group
4 от 4
27.2.2007 г. 12:46