Saturday, April 30, 2011

Introduction to Embedded Systems

  • Introduction
  • Embedded Hardware
  • Embedded Software
  • Embedded Development Tools

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.



Monday, April 18, 2011

Introduction to ARM Cortex M3 and STM32 - Part II

This is the second post after the first tutorial.
  • STM32 System Architecture
  • Peripherals
  • Low Power Operation
  • Safety Features
  • The Flash Module
  • Development Tools

Introduction to ARM Cortex M3 and STM32 - Part I

  • Introduction
  • Cortex Overview
  • CMSIS
Introduction to stm32-part1
View more presentations from amraldo

You can find the second part here