Skip to content
Snippets Groups Projects
Commit b94e91c6 authored by Joakim Nohlgård's avatar Joakim Nohlgård
Browse files

kinetis: Adjust RTT alarm trigger time

The RTT alarm will trigger when the RTT seconds register is equal to the
set alarm target, instead of triggering at the following second.
parent 03caac89
No related branches found
No related tags found
No related merge requests found
......@@ -126,12 +126,15 @@ void rtt_set_counter(uint32_t counter)
void rtt_set_alarm(uint32_t alarm, rtt_cb_t cb, void *arg)
{
/* The alarm is triggered when TSR matches TAR, and TSR increments. This
* seem counterintuitive as most users expect the alarm to trigger
* immediately when the counter becomes equal to the alarm time. */
RTC_Type *rtt = RTT_DEV;
/* Disable Timer Alarm Interrupt */
rtt->IER &= ~(RTC_IER_TAIE_MASK);
rtt->TAR = alarm;
rtt->TAR = alarm - 1;
rtt_callback.alarm_cb = cb;
rtt_callback.alarm_arg = arg;
......@@ -147,7 +150,7 @@ void rtt_set_alarm(uint32_t alarm, rtt_cb_t cb, void *arg)
uint32_t rtt_get_alarm(void)
{
RTC_Type *rtt = RTT_DEV;
return rtt->TAR;
return rtt->TAR + 1;
}
void rtt_clear_alarm(void)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment