PIC24 counting semaphores:

paraparvy wrote on Sunday, July 03, 2016:

Hi All,

Having difficulty in tyring to create counting semaphores in PIC24 port.

SemaphoreHandle_t xCountingSemaphore;

xCountingSemaphore = xSemaphoreCreateCounting(5,0);

The above lines generate the following errors: (…can’t see anything to configure in FreeRTOSConfig.h
i.e configSUPPORT_DYNAMIC_ALLOCATION is not defined)

============================================================================
nbproject/Makefile-impl.mk:39: recipe for target ‘.build-impl’ failed
build/default/production/_ext/1472/main_Interrupt_BinSema_Tut.o(.text+0x8c): In function .L0': : undefined reference to _xQueueCreateCountingSemaphore’
build/default/production/_ext/1472/main_Interrupt_BinSema_Tut.o(.text+0x8e): In function .L0': : undefined reference to _xQueueCreateCountingSemaphore’
make[2]: *** [dist/default/production/FreeRTOS_Tutorial.X.production.hex] Error 255
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 3s)

================================================================================

Thanks

rtel wrote on Sunday, July 03, 2016:

If you look at the implementation of xQueueCreateCountingSemaphore() you
will see it is guarded by:

#if( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( 
configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )

Do you have both configUSE_COUNTING_SEMAPHORES and
configSUPPORT_DYNAMIC_ALLOCATION set to 1?

paraparvy wrote on Monday, July 04, 2016:

Hi,
Thanks for getting back.

No, configUSE_COUNTING_SEMAPHORES and configSUPPORT_DYNAMIC_ALLOCATION
do not appear to be declared anywhere…or at least i could’t find them.

Should I define and set them in FreeRTOSConfig.h ?

Cheers

davedoors wrote on Monday, July 04, 2016:

Only if you want to use counting semaphores.

paraparvy wrote on Monday, July 04, 2016:

OK, thanks Dave

paraparvy wrote on Monday, July 04, 2016:

Hi All,

Counting semaphores are now OK…having trouble compling Mutex:

SemaphoreHandle_t xMutex;
xMutex = xSemaphoreCreateMutex();

configSUPPORT_DYNAMIC_ALLOCATION is set to 1 in FreeRTOSConfig.h
…and i think that is all that is needed in semphr.h

Cheers

=======================================
nbproject/Makefile-impl.mk:39: recipe for target ‘.build-impl’ failed
build/default/production/_ext/1472/main_Mutex1_Tut.o(.text+0x50): In function .L0': : undefined reference to _xQueueCreateMutex’
build/default/production/_ext/1472/main_Mutex1_Tut.o(.text+0x52): In function .L0': : undefined reference to _xQueueCreateMutex’

rtel wrote on Monday, July 04, 2016:

Either search for the word “Mutex” on the configuration options web page
(http://www.freertos.org/a00110.html), or search for xQueueCreateMutex
in the source code (the “queue” in the function name tells you it is
implemented in queue.c) - then you will be able to answer your own question.

paraparvy wrote on Monday, July 04, 2016:

OK, needed to declare and set configUSE_MUTEXES, all fine now
Thank you so much