Quality RTOS & Embedded Software

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


Loading

Resource management

Posted by Thomas on July 8, 2013
Hi,

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?

regards
Thomas

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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



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

Renesas

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