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


Resource management

Posted by Thomas on July 8, 2013

I have a question about mutexes and semaphores.
Is it possible to use a mutex (or semaphore) to control the access to a peripheral within one task?
I want to implement a block data transfer. Therefore I want to generate a mutex which is taken before the data is written to the peripheral. If the peripherals FIFO is empty I want an interrupt service routine to give the mutex back so that the next data can be sent.
I have already tried to implement this behavior but without success.
The xSemaphoreTake(SBP_ClientTxSem, 0x00) function does not block before the mutex was given by the ISR. This produces data loss.
Can anybody help me?


RE: Resource management

Posted by Dave on July 8, 2013
That is the normal way of doing it, but if it is only used by a single task use a binary semaphore instead of a mutex.

In you post the second parameter to xSemaphroeTake() is zero, so the block time is 0 and the function will return right away. If you want to wait for a finite time then set the second parameter to the number of ticks you want to block and check the return value to see if the semaphore was taken (true) or if the call timed out (false).

RE: Resource management

Posted by Thomas on July 9, 2013
Hi davedoors,

thank you for your quick reply.
Unfortunately I misinterpreted the sentence "A block time of zero can be used to poll the semaphore."

It works perfectly.

Thank you

[ 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