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




Loading

Semaphore doesn't seem to work

Posted 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 work

Posted 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 work

Posted 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 work

Posted 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!


[ 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