FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [June 2014 Threads]
Hi,
must something special be taken into account when using a RTC with FreeRTOS?
The code works fine without RTC. Once the RTC code is integrated to throw an alarm/interrupt, the system runs in a undefined state.
int main( void )
{
// includes the RTC setup
prvSetupHardware();
NVIC_DisableIRQ(RTC_IRQn);
// C++ based xTaskCreate function
pearlrt::t_TASK3.activate()
NVIC_EnableIRQ(RTC_IRQn);
// set RTC second to 0
RTC_SetTime(LPC_RTC, RTC_TIMETYPE_SECOND, 0);
// throw alarm/interrupt on second 10
RTC_SetAlarmTime (LPC_RTC, RTC_TIMETYPE_SECOND, 10);
/* Start the scheduler. */
vTaskStartScheduler();
/* IDLE task is used */
}
// --------- prvSetupHardware() ------------------
void prvSetupHardware( void )
{
[...]
// Enable RTC
init_RTC();
}
// --------- init_RTC()--------------------------
void init_RTC(void)
{
RTC_Init(LPC_RTC);
NVIC_DisableIRQ(RTC_IRQn);
NVIC_SetPriority(RTC_IRQn, ((0x01<<3)|0x01));
RTC_Cmd(LPC_RTC, ENABLE);
RTC_AlarmIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE);
NVIC_EnableIRQ (RTC_IRQn);
}
// --------- RTC_IRQHandler() ---------------------
void RTC_IRQHandler()
{
if (RTC_GetIntPending(LPC_RTC, RTC_INT_ALARM))
{
debugMessage("Alarm");
// Clear pending interrupt
RTC_ClearIntPending(LPC_RTC, RTC_INT_ALARM);
}
}
I don't see you setting the interrupt priority BEFORE enabling it.
I was actually the opinion that the RTC must be reinitialized whenever the program (re-)starts but if I remove init_RTC() from prvSetupHardware(), everything works as expected. Reboot, reset the device, everything seems ok ... weird!
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.