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] [March 2015 Threads] Counting Semaphore Loses Count???Posted by sfalias on March 11, 2015 Hi,
I'm new to FreeRTOS though I have a lot of experience with other RTOSs.
I have a serial stream coming into a UART interrupt where the characters are stored in a large buffer. I'm trying to use a counting semaphore to count one particular character, lets call it FLAG, coming in on the UART. For each FLAG, I want to Give the semaphore to a task. In my task, I pend on a Take, then read from buffer until I get FLAG, then I pend for the next Take.
This works fine until I send a lot of messages. Eventually, my task hangs on Take. Doing this in a debugger, I can stop and look at my buffer. I can see the last Take stopped at the next to last FLAG, but I can also see the UART received more characters and another FLAG that are sitting in the buffer unread.
I tried to dig into FreeRTOS to see if I could find the actual count of the semaphore when a FLAG is in the buffer but the Take doesn't see it, but all I can find is a void * and don't know where the count is. I did put in a global counter on Give and Take and I find that Give is always 1 greater than Take when the hang occurs.
It appears the Give worked but the Take didn't see it. At this point I don't know what else to think other than this is a critical timing issue.
Anyone have any ideas on how I might find this problem?
Thanks,
Dave
Counting Semaphore Loses Count???Posted by rtel on March 11, 2015 To ensure our answer is targetted, please let us know which FreeRTOS port are you using (chip and compiler).
Regards.
Counting Semaphore Loses Count???Posted by sfalias on March 11, 2015 Hi, sure. I didn't think it was important, but hey, if I knew what was going on I wouldn't have posted.
V8.1.2
PIC32MX460, 470 and 575.
Thanks.
Dave
Counting Semaphore Loses Count???Posted by rtel on March 11, 2015 What is the value of configMAXSYSCALLINTERRUPT_PRIORITY in FreeRTOSConfig.h?
Have you set the priority of the interrupt to ensure it is at or below the configMAXSYSCALLINTERRUPT_PRIORITY setting?
Which method are you using to implement the interrupt? With or without the assembly wrapper? The methods are described on http://www.freertos.org/portPIC32MIPS_MK4.html
Maybe not directly related to your question, but if it is always the same task that is being signaled from the interrupt then a task notification will be faster than a counting semaphore: http://www.freertos.org/RTOSTaskNotificationAsCounting_Semaphore.html
Regards.
Counting Semaphore Loses Count???Posted by sfalias on March 11, 2015 OK, I'm old school. Intuitively (to me), I always make UART ISRs higher priority to avoid dropping characters. But doing that put the UART above configMAXSYSCALLINTERRUPT_PRIORITY. I've lowered the UART priority to 3 (same as that macro) and am now testing. So far, 60K+ messages without a failure, 5x more than before. So it appears you've found my problem. And so quickly too!
THANKS A TON!
Dave
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|