I am using the Cortex_M4_ATSAM4L_Atmel_Studio in low power mode for my applications. I am doing some stability testing and have found that my build crashes within 24 hours. My build is using the ast timer as the ticks for freertos as the demo provides. I created an interrupt that uses a semaphore to resume a task. My interrupts are coming in at 200hz and set the priority level to be configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY. When running this The system freezes in under 24 hours. In this freezing I noticed the ast interrupts (ticks for freertos) and my external interrupts stop coming in also.
This is how I set my interrupts.
and set the priority level to be configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY
There is a comment in the code as follows:
/* Tick interrupt MUST execute at the lowest interrupt priority. */
Try setting the priority level to configLIBRARY_LOWEST_INTERRUPT_PRIORITY.
Also, when the ticks stop, look at the alarm value. While creating a low power demo for another port I ensured the equivalent of the alarm value is never set to 0. It doesn’t look like the same check is included in the SAM4L demo in the following place in the code:
/* The alarm value is set to whatever fraction of a single tick period remains. */
ulAlarmValue = ast_read_counter_value( AST ) - ( ulCompleteTickPeriods * ulAlarmValueForOneTick );
ast_write_alarm0_value( AST, ulAlarmValue );
Try adding the following lines in between those two lines (which are in SAM4L_low_power_tick_management.c).
if( ulAlarmValue == 0 )
{
/* There is no fraction remaining. */
ulAlarmValue = ulAlarmValueForOneTick;
ulCompleteTickPeriods++;
}
Yes I set the priority level of my other interrupt to be configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY. I don’t believe the error occurs in the portSuprressTicksAndSleep function. I have led toggle checks in that function and the error appears to occur out of the function. I am guessing that maybe some in freertos it is disabling the interrupts in a critical section and somehow fail to enable the interrupts.
Has anyone ever used the freertos low power demo on cortex M4 to run with other interrupts coming in? A reference guide on how to use external interrupts with this low power demo would also help.