Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists