Friday, April 22, 2011

New Software Timers in FreeRTOS under MS Windows

SW Timers
Embedded applications need to schedule future events. This can be accomplished using timers and timers' services.

Timers are an integral part of any real-time system. A timer can be seen as an event scheduling according to a predefined time value in the future, exactly like setting an alarm clock.

Embedded systems that have time-sensitive activities use 2 types of timers; hard-timers and soft-timers. Hard timers are based on physical timers on the chip that directly interrupt the CPU. A hard-timer is a must in case of an application demanding high precision and predication. On the other hand soft-timers are scheduled through a software facility that enables soft-timer's maintenance, installation, and removal.

But if hard-timers are more accurate than their soft counterparts, why are they used? The answer is in their nature. The can be programmed with timeouts of course granularity. In addition, the high-precision is not always needed in most of embedded systems. Another prevailing reason is reducing system interrupt overhead. Facilities of soft-timers are built using only 1 hardware-timer.


SW Timers in FreeRTOS
Starting from FreeRTOS V7.0.0, FreeRTOS added the soft-timers feature. FreeRTOS timers have 2 modes of operations; autorelaod and 1-shot modes. Whenever a timer timeouts, a callback function is executed. This service is implemented as a FreeRTOS kernel task and a FreeRTOS queue. This task is assigned a stack size and priority defined the macros configTIMER_TASK_STACK_DEPTH and configTIMER_TASK_PRIORITY respectively. The timers APIs are implemented through the queue. Whenever a task calls a timer API it send s a command to the timer task through the timers queue. This task continually gets the next expire time, either process the expired timer or blocks until a timer expires or  it receives a command  and processes it. Like any other FreeRTOS service, this service is highly configurable. In order to use it you have to:
  1. Define configUSE_TIMERS to 1
  2. Define configTIMER_TASK_PRIORITY and configTIMER_STACK_DEPTH
  3. Define configTIMER_QUEUE_LENGTH
  4. Add FreeRTOS/Source/timers.c to your application.
  5. Use the timers in your application

Demoing the SW Timers under MS Windows
Last year, I showed how to run the industrial PC port under MS Windows. Recently, FreeRTOS team made a windows simulator. Unlike the PC port that used Open Watcom and 80x86 assembly, it uses MS VC or MingW and Windows APIs. 

The following steps shows how to test the SW timers with the FreeRTOS MS Windows simulator:
  1. Download MS VC++ 2010 Express edition from here.
  2. After Installing the compiler, download FreeRTOS from here.
  3. Open the project using MS VC and here you go.



11 comments:

  1. However if hard-timers end up being more valid when compared to their cushy alternatives, the reasons why are really they used? The answer is within their character. The can feel programmed with timeouts naturally granularity. In addition, the high-precision is certainly not always needed in many of embedded techniques. An additional prevailing cause is decreasing system interrupt overhead. Amenities of soft-timers are built using just 1 hardware-timer.automateandvalidate

    ReplyDelete
  2. Our Embedded Training Institute Provides 100 % Training & Placements. Embedded (8051, PIC, AVR, RTOS).Projects also Provides in Best & affordable fees Structure.Call @ +91-9940426826 / 044-26209369.
    Best Embedded Systems Training Institute

    ReplyDelete
  3. Thank you for this awesome and wonderful post!! keep it up!
    Crack Software Download

    ReplyDelete
  4. Amazing discussion on software technology. Go ahead and update us through these type of posts Adobe Photoshop Serial Number Free Download

    ReplyDelete
  5. Thanks for sharing this article which content Contact No, Toll free no and address of Flipkart customer care
    Flipkart Toll Free No

    ReplyDelete
  6. Welcome to Wiztech Automation - Embedded System Training in Chennai. We have knowledgeable Team for Embedded Courses handling and we also are after job placements offer provide once your successful completion of Course We are Providing on Microcontrollers such as 8051, PIC , AVR, ARM7, ARM9, ARM11 and RTOS. Free Accommodation, Individual Focus, Best Lab facilities, 100% Practical Training and Job opportunities.

    Embedded System Training in chennai
    Embedded System Training Institute in chennai
    Embedded Training in chennai
    Best Embedded System Training in chennai
    Embedded System Training in chennai
    Best Embedded System Training Institutes in chennai

    ReplyDelete
  7. Embedded system training: Wiztech Automation Provides Excellent training in embedded system training in Chennai - IEEE Projects - Mechanical projects in Chennai. Wiztech provide 100% practical training, Individual focus, Free Accommodation, Placement for top companies. The study also includes standard microcontrollers such as Intel 8051, PIC, AVR, ARM, ARMCotex, Arduino, etc.

    Embedded system training in cehnnai
    Embedded training in chennai
    Best Embedded system training in chennai
    Embedded sytsem training institute in chennai
    Embedded projects in chennai
    VLSI training in chennai
    VLSI training institute in chennai

    ReplyDelete