Quality RTOS & Embedded Software

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


Loading

Problem using a minary semaphore

Posted by barber colman on August 18, 2010
I have a serial communications task and a display task. The serial task creates a binary semaphore at task initialization
vSemaphoreCreateBinary( xPacketReceivedSemaphore );
The receive interrupt gives the semaphore after a packet is received.
xSemaphoreGiveFromISR( xPacketReceivedSemaphore, &xHigherPriorityTaskWoken );
The serial task sends a new request for a packet of data after receiving a packet or one second without receiving a packet
if( xSemaphoreTake( xPacketReceivedSemaphore, (1000 / portTICK_RATE_MS) ) == pdTRUE ){
This process works well as long as communications is started before the display task starts. If the display task before the first packet is received the serial task get to the xSemaphoretake and never returns.

Any idea what is happening? This processor is not starved. the vApplicationIdleHook is being called. I am using freeRtos 6.03 and a PIC32MX.

RE: Problem using a minary semaphore

Posted by Richard Damon on August 18, 2010
The first question is what does the display task have anything to do with the serial operation?

Second, the take you have shown will return after the second (unless you have corrupted something or the time has stopped). If a packet isn't sent and the semaphore raised, it will return pdFALSE and not go into the statements controlled by the if, so that clause should only process the previous packet, and after the if, should be the statement to request the next one..

RE: Problem using a minary semaphore

Posted by barber colman on August 19, 2010
It is a very good question. It should not, but it does.

When it works a new packet is sent as soon as the last packet is returned. If a packet is not responded to a new packet will be sent after the 1 second delay.

This does work but only when a packet has been sent and responded to before the graphics task has started. It does not make sense to me. I think my next step is to look in task.c and see why the communications task is not running.

Thanks








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


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

Careers

FreeRTOS and other embedded software careers at AWS.


Latest News

FreeRTOS kernel V10.0.1 is available for immediate download. Now MIT licensed.


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