scoping of xBinarySemaphore?
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?
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?
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?
Yes, I tracked down the example code and see the semaphore declared with global scope outside main(). Thanks!