Cortex M4 Low power interrupt

jabad06 wrote on Sunday, December 08, 2013:

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.

	struct eic_line_config eic_line_conf;
	ioport_set_pin_mode(PIN_PA16, MUX_PA16C_EIC_EXTINT1 | IOPORT_MODE_PULLUP);
	/* Setup Motion interrupt PIN as EIC*/
	eic_line_conf.eic_mode = EIC_MODE_EDGE_TRIGGERED;
	eic_line_conf.eic_edge = EIC_EDGE_FALLING_EDGE;
	eic_line_conf.eic_level = EIC_LEVEL_LOW_LEVEL;
	eic_line_conf.eic_filter = EIC_FILTER_DISABLED;
	eic_line_conf.eic_async = EIC_ASYNCH_MODE;
	eic_line_set_config(EIC, EXT_INT1,
	eic_line_set_callback(EIC, EXT_INT1, cb,
	EIC_1_IRQn, 1);
	eic_line_enable(EIC, EXT_INT1);
	static void cb(){
        void task(){
                    //toggle led

I also did a separate test where my external interrupts has a priority 1 and they constantly come in while the ast stops coming.

rtel wrote on Sunday, December 08, 2013:

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;


rtel wrote on Sunday, December 08, 2013:


Note that change will only make a difference if something other than the tick interrupt brings the MCU out of its sleep state.


jabad06 wrote on Monday, December 09, 2013:

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.