Quality RTOS & Embedded Software

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


Solving an INTERRUPTing puzzle

Posted by ammaree on September 5, 2015

In an application I am developing I have come across a puzzling situation. The background is as follows: Hardware is standard CC3200 LaunchPad Software using CC3200 SDK v1.1.0 and FreeRTOS 8.2.2, Environment using latest Code Composer Studio (CCS) v6.1.0.104

ASSERT is enabled for all my code as well as the SDK driverlib, simplelink and oslib components and tested to trigger everywhere. configASSERT is enabled for FreeRTOS and tested to trigger if I on purpose change (to an invalid value) configMAXSYSCALLINTERRUPT_PRIORITY.

Although the CC3200 is M4 architecture (without FPU) the official SDK ships with an older version of FreeRTOS (8.0.1) and provides a ARMCM3 port as opposed to an ARMCM4 port.

In order to overcome some challenges with the CM3 implementation I adapted the latest official FreeRTOS CCS ARM_CM4F port by simply removing the VFP related code, nothing else.

Originally I only used taskENABLEINTERRUPT() and taskDISABLEINTERRUPT() function and everything worked perfectly

I then decided to change all references to taskENTERCRITICAL() and taskEXITCRITICAL() and that is where the mystery started.....

The application now fails in various places, stages and modes, but always in a way where debugging is impossible, no debug exception handler triggering, no stack trace, nothing.

  • Stack size is not a problem, all tasks have at all times a minimum of 972 to 2848 bytes unused.
  • I have tried module by module to determine if the problem only occurs in s certain function, no luck.
  • If I use tasKENTER/EXIT_CRITICAL() anywhere it crashes.
  • Change all references to taskEN/DISABLE_INTERRUPTS and it runs rock solid.
  • Only xTaskNotifyFromISR and portYIELDFROMISR is used in 1 routine, no other API calls from ISRs

What am I missing since I did not touch any of the related code in the port...

All help appreciated.


Solving an INTERRUPTing puzzle

Posted by rtel on September 5, 2015

Thanks for proving information on what you have already tried - it would be nice if more people did that.

First - we don't have an official ARMCM3 port for CCS, so originally you are using third party and unsupported code. We do have an official ARMCM4F port for CCS, so guess the code you adapted is from the official code base - altbeit that you have made the ataptions yourself so we can't discount that being a potential source of error.

Although the CC3200 is M4 architecture (without FPU) the official SDK ships with an older version of FreeRTOS (8.0.1) and provides a ARMCM3 port as opposed to an ARMCM4 port.

It is correct to use the ARM_CM3 port if the part does not have an FPU, but as mentioned about, there isn't official for for CM3 and CCS. With the other supported compilers the only difference between the CM3 and CM4F ports is the FPU support.

Originally I only used taskENABLEINTERRUPT() and taskDISABLEINTERRUPT() function and everything worked perfectly

Normally we would advice against using those macros directly, in favour of using the taskENTERCRITICAL() and taskEXITCRITICAL() macros as the latter count the nesting depth...

...and maybe this could be a clue to what your problem is?

When you call taskENABLEINTERRUPTS() interrupts will get fully enabled no matter what. When you call taskEXITCRITICAL() interrupts will only get fully enabled if the critical section nesting count is zero. Although I can't say why that would prevent you from being able to debug - you should be able to debug easily even when in a critical section.

How long does it take for this issue to occur? Does it occurr immediately, or after a while.

.... if it occurs immediately can you inspect the value of uxCriticalNesting in FreeRTOSSourceportableCCSARM_CM4F. To start with, when main() is called, it should be 0xaaaaaaaa. If it is not that value then it is not being initialised correctly. When the first task starts running (on entry to the first task, which could be the timer task created by FreeRTOS itself) it should be 0.

.... if it occurs after some time, is it always after a particual function is called, or after a particular event occurs (interrupt executes, etc.)? If so, could it be something inside one of the libraries is accessing interrupt masks in a way that is not compatible with FreeRTOS? FreeRTOS uses the BASEPRI register, so it is ok for libraries to globally enable/disable interrupts in the processor itself (provided they are enabled again), but there could be problems if a libary leaves BASEPRI in an unexpected state, or enables all interrupts when FreeRTOS expects them to be partially masked.


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

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

Latest News

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

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

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

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