Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Cortex M4 Low power interrupt

Posted by jabad06 on December 8, 2013

I am using the CortexM4ATSAM4LAtmelStudio 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 configLIBRARYMAXSYSCALLINTERRUPTPRIORITY. 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 eiclineconfig eiclineconf;

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(){ SemaphoreGiveFromISR(semid); } void task(){ for(;;){ if(SemaphoreTake(semid){ //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.

Cortex M4 Low power interrupt

Posted by rtel on December 8, 2013

and set the priority level to be configLIBRARYMAXSYSCALLINTERRUPTPRIORITY

There is a comment in the code as follows:

/* Tick interrupt MUST execute at the lowest interrupt priority. */

Try setting the priority level to configLIBRARYLOWESTINTERRUPT_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 = astreadcountervalue( AST ) - ( ulCompleteTickPeriods * ulAlarmValueForOneTick );
astwritealarm0value( AST, ulAlarmValue );

Try adding the following lines in between those two lines (which are in SAM4Llowpowertickmanagement.c).

if( ulAlarmValue == 0 )
    /* There is no fraction remaining. */
    ulAlarmValue = ulAlarmValueForOneTick;


Cortex M4 Low power interrupt

Posted by rtel on December 8, 2013

See https://sourceforge.net/p/freertos/code/HEAD/tree/trunk/FreeRTOS/Demo/CORTEXM4ATSAM4LAtmelStudio/src/SAM4Llowpowertickmanagement.c

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


Cortex M4 Low power interrupt

Posted by jabad06 on December 9, 2013

Yes I set the priority level of my other interrupt to be configLIBRARYMAXSYSCALLINTERRUPTPRIORITY. 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.

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers





STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner