Hi Seb,
On 2011/04/06 15:28, Sebastien Lelong wrote:
I don't use RTCC pin, but would like to control a LED on another pin,
when alarm is active. Unfortunately I can't find any interrupt strictly
related to alarm events. RTCC pin can be driven with alarm interrupts,
but there's no actual register to read from.
Do I miss something ? I surely do... Currently, in ISR, I read time and
check if equals to alarm time.
I don't remember exactly why I chose for the bcd-notation with MSB first
(yymmdd and hhmmdd), but this is not so comfortable when comparing
values of date and time for larger or smaller. Therefore the library
contains functions which return binary values for relative second or
minute of the day. But there are currently no functions for day of the
year or days since 1 Jan. 2000. Would it be useful to add these?
If so, alarm is active:
--
rtc_init()
rtc_calibrate(0)
-- let's say we're April 23rd 2011, it's 10:56:12 o'clock.
-- Alarm is set at 10:56:17
var byte*3 datenow = 0x230411
var byte*3 timenow = 0x125610
var byte*3 alarmtime = 0x175610
rtc_set_yymmdd_bcd(datenow)
rtc_set_hhmmss_bcd(timenow)
rtc_set_alarm_hhmmss_bcd(alarmtime)
rtc_set_alarm(true)
rtc_set_alarm_period(RTC_ALARM_PERIOD_SECOND)
rtc_set_alarm_repeat(10)
-- isr
var bit alarm_is_ringing = false
procedure school_is_over() is
pragma interrupt
if ! PIR3_RTCCIF then
return
end if
if !alarm_is_ringing then
timenow = rtc_get_hhmmss_bcd()
if timenow == alarmtime then
alarm_is_ringing = true
end if
end if
if alarm_is_ringing != 10 then
if ALRMRPT then
onboard_led = !onboard_led
end if
end if
PIR3_RTCCIF = false -- clear flag
end procedure
Results: LED is blinking 5 times: on, off, on, off, on. Every 1s. But it
should blink 10 times, as repeat 10 and period = 1s.
I cannot put the finger on the hot spot by reading your code, but I'll
copy your program and try to find what's wrong.
I would prefer read a register to know if alarm is currently ringing...
What do you mean exactly? Should the library provide a bit or function
for this?
Regards, Rob.
--
R. Hamerling, Netherlands --- http://www.robh.nl
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.