Quality RTOS & Embedded Software

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


scoping of xBinarySemaphore?

Posted by jack-king on February 10, 2019

Hello, I am working through the Cortex-M3 FreeRTOS guide and reviewing the Example 12 for interrupts and binary semaphores.

Looking at the main() function that creates the xBinarySemaphore handle in Listing 48... how is the semaphore handle in scope for the ISR handler?

I am using a hardware GPIO ISR and get a scoping error when trying to access the semaphore in the ISR.

scoping of xBinarySemaphore?

Posted by richarddamon on February 10, 2019

I don't have that manual/listing in front of me, but generally I put FreeRTOS item handles at global scope (or part of a structure that is at global scope) to make it easier for the different pieces to access it.

In general, and especially for things like the Cortex-M3, there shouldn't be items declared in the scope of main (maybe a loop counter for loops in the setup code in main), as those aren't available to other functions, and on many ports, the Arm included, the main function stack gets reused as the interrupt stack, so any object declared their might get overwritten.

scoping of xBinarySemaphore?

Posted by rtel on February 10, 2019

Looking in the book text, it doesn't show where the semaphore is declared, but you have the source code available too so you can look in there. I would suspect it will be a file scope static.

scoping of xBinarySemaphore?

Posted by jack-king on February 10, 2019

Yes, I tracked down the example code and see the semaphore declared with global scope outside main(). Thanks!

[ 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