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] [May 2007 Threads] Semaphore doesn't seem to workPosted by Torben on May 9, 2007 Hi!
In my application I create a semaphore to control access to a global structure which holds the acual time, which is beeing read out a RTC in a task. In another task I create log entrys, including the time. In both tasks, the access to the structure is protected by the semaphore. I initialize the "time reading task" before the log task, so the time should be read out before any log entry is created. Even so the first log entrys contain a wrong time. How is this possible. As long as the time reading task holds the semaphore the log task should not be able to access the time keeping structure. Unfortunately my debugger (using IAR Embedded Workbench) is not able to debug this, I get a message stating "simulating illegal code condition". Now I am wondering how this is possible. Preemption is enabled and both tasks have the same priority. But this should not be important as I am using the semaphore. Has anyone an idea on this?
ThX!
RE: Semaphore doesn't seem to workPosted by Nobody/Anonymous on May 9, 2007 From the error it sounds like you are running it in the simulator. Is this the case. I don't think the IAR simulator simulated peripherals.
RE: Semaphore doesn't seem to workPosted by Torben on May 9, 2007 No it runs on hardware with a SAM-ICE connected. The error is not the problem. I figured out so much: The RTC Read task is started before the Log Task. It runs beyond the take semaphore command and starts updating the clock structure. I then have to let it run, else I encounter the prior mentioned error. The Log task is entered thereafter (I have a breakpoint here). If I debug it, sometimes the time is correctly set prior to the first log entry and sometimes not. Is it possible that the tasks start in a casual order, so sometimes the log task has first access and sometimes not? I don't really think so but this would be an explanation. On the other hand: If the time is not correct, parts of the time are right, e.g. seconds and minutes, but not the hours, which is for me a hint that the RTC Task is being interrupted and the semaphore does not work. So far this only happens at startup. Before using a semaphore I had glitches in the displayed time several times, they are all gone with the introduction of the semaphore, only this startup problem is left. I have firgured out a workaround which is reading the clock directly before staring the scheduler, nonetheless I would like to find the problem there.
I don't think my explanation is very good, but I hope you can still get the problem.
RE: Semaphore doesn't seem to workPosted by Torben on May 9, 2007 Update:
I think I figured out the problem: It is not the semaphore it is the TWI which is use to read the RTC (I²C). Some or all Values seem to be read out wrong sometimes at startup, but not always. I thought the TWI routines work ok because they did till now. The errors seem only to occur at startup. So everything with the semaphores is fine!
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|