FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [July 2013 Threads] Resource managementPosted 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 managementPosted 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 managementPosted 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
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|