Renesas Electronics America Inc.
© 2012 Renesas Electronics America Inc. All rights reserved.
Software Development with an
Open Source RTOS
© 2012 Renesas Electronics America Inc. All rights reserved.2
Renesas Technology & Solution Portfolio
© 2012 Renesas Electronics America Inc. All rights reserved.3
Microcontroller and Microprocessor Line-up
Wide Format LCDs
Industrial & Automotive, 130nm
350µA/MHz, 1µA standby
44 DMIPS, True Low Power
Embedded Security, ASSP
165 DMIPS, FPU, DSC
1200 DMIPS, Performance
1200 DMIPS, Superscalar
500 DMIPS, Low Power
165 DMIPS, FPU, DSC
25 DMIPS, Low Power
10 DMIPS, Capacitive Touch
Industrial & Automotive, 150nm
190µA/MHz, 0.3µA standby
Industrial, 90nm
242µA/MHz, 0.2µA standby
Automotive & Industrial, 90nm
600µA/MHz, 1.5µA standby
Automotive & Industrial, 65nm
600µA/MHz, 1.5µA standby
Automotive, 40nm
500µA/MHz, 35µA deep standby
Industrial, 40nm
242µA/MHz, 0.2µA standby
Industrial, 90nm
1mA/MHz, 100µA standby
Industrial & Automotive, 130nm
144µA/MHz, 0.2µA standby
2010
2013
32-bit8/16-bit
© 2012 Renesas Electronics America Inc. All rights reserved.4
Microcontroller and Microprocessor Line-up
Wide Format LCDs
Industrial & Automotive, 130nm
350µA/MHz, 1µA standby
44 DMIPS, True Low Power
Embedded Security, ASSP
165 DMIPS, FPU, DSC
1200 DMIPS, Performance
1200 DMIPS, Superscalar
500 DMIPS, Low Power
165 DMIPS, FPU, DSC
25 DMIPS, Low Power
10 DMIPS, Capacitive Touch
Industrial & Automotive, 150nm
190µA/MHz, 0.3µA standby
Industrial, 90nm
242µA/MHz, 0.2µA standby
Automotive & Industrial, 90nm
600µA/MHz, 1.5µA standby
Automotive & Industrial, 65nm
600µA/MHz, 1.5µA standby
Automotive, 40nm
500µA/MHz, 35µA deep standby
Industrial, 40nm
242µA/MHz, 0.2µA standby
Industrial, 90nm
1mA/MHz, 100µA standby
Industrial & Automotive, 130nm
144µA/MHz, 0.2µA standby
2010
2013
32-bit8/16-bit
32-Bit High Performance
DSP, FPU with High Integration
© 2012 Renesas Electronics America Inc. All rights reserved.5
‘Enabling The Smart Society’
DVR
Game Console
Smart Phones
Navigation
Systems
Music Players
Tablet PC
© 2012 Renesas Electronics America Inc. All rights reserved.6
Agenda
Definitions
Why RTOS?
Why FreeRTOS?
Lab Exercises
Questions
Feedback Form
© 2012 Renesas Electronics America Inc. All rights reserved.7
Definitions, RTOS, and FreeRTOS
© 2012 Renesas Electronics America Inc. All rights reserved.8
What is Your RTOS Experience?
I have previously used an RTOS in a commercial product
I am using an RTOS in my current project
I am considering using an RTOS in the near future and
would like to get as much info as possible
I am a “Super-Loop” user and here to burn you down
© 2012 Renesas Electronics America Inc. All rights reserved.9
Some Definitions
REAL-TIME: Computing with a deadline
Hard real-time (Air bag)
Soft real-time (Adaptive volume)
TASK: Self contained code that handles a singular
functionality or semi-independent portion of an application
Process
Thread
SCHEDULER: Implements the scheduling policy
Kernel
Operating system (OS)
PRIORTY: Used in arbitration mechanism
© 2012 Renesas Electronics America Inc. All rights reserved.10
Why Use an RTOS? (1 of 2)
Abstracting timing information
Kernel is responsible for system time
Modularity
Tasks are independent modules with well defined purpose
Team development
Designers can work on different tasks simultaneously
Code reuse
Modules allow code re-use with less effort
Improved efficiency
Event driven software
Code executes only when it is needed
© 2012 Renesas Electronics America Inc. All rights reserved.11
Why Use an RTOS? (2 of 2)
Flexible interrupt handling
Short interrupt routines that detects events
Most of the work deferred to a task
Mixed processing requirements
Periodic execution
Continuous functions
Event driven processing
Real-time requirement ordering with priorities
Control over peripherals
Shared resources
Gatekeeper tasks
© 2012 Renesas Electronics America Inc. All rights reserved.12
Why FreeRTOS?
Widely used and known
Open source
Simple and easy to port
Feature rich but small size
Free use and distribute
Path to commercial versions
OpenRTOS: Full support, additional components
SafeRTOS: Functional safety, IEC 61508 compliant
More on FreeRTOS site
/> />© 2012 Renesas Electronics America Inc. All rights reserved.13
What is our role with FreeRTOS?
Port FreeRTOS to Renesas MCUs
Work with FreeRTOS to qualify ports
Provide sample projects with FreeRTOS
Direct Drive LCD
Firmware Integration Technology (FIT)
Support by FreeRTOS
Partner with other RTOS vendors for full support
Micrium: uc/OS
Segger: embOS
CMX: CMX-RTX
© 2012 Renesas Electronics America Inc. All rights reserved.14
Lab Exercises
© 2012 Renesas Electronics America Inc. All rights reserved.15
General Notes on Lab Exercises
Refer to lab handout
Total of 6 lab exercises
Short description up
front
About 10-minute labs
Recap at end
LEDs show running task
LED5 Task1
LED6 Task2
LED7 Task3
LED8 Task 4
LED9 Run time stats
LED10 Idle Task
© 2012 Renesas Electronics America Inc. All rights reserved.16
Lab Exercise 1 - Tasks, Priorities, Task States
© 2012 Renesas Electronics America Inc. All rights reserved.17
Lab Exercise 1 - Tasks, Priorities, Task States
APIs: xTaskCreate(),
vTaskDelay(),
vTaskDelayUntil(),
vTaskStartScheduler()
Pre-emptive scheduling
Highest priority ready task
Time slice same priority
tasks
Idle task
Low priority background or
continuous tasks
Spare processing time
System in low power
MUST NOT BLOCK!
Suspended
Ready
Blocked
Running
vTaskSuspend()
vTaskSuspend() vTaskResume()
vTaskSuspend()
Event
Blocking API function
© 2012 Renesas Electronics America Inc. All rights reserved.18
Lab Exercise 1 – You can start the lab now
© 2012 Renesas Electronics America Inc. All rights reserved.19
Lab Exercise 1 – Recap (1 of 3)
© 2012 Renesas Electronics America Inc. All rights reserved.20
Lab Exercise 1 – Recap (2 of 3)
© 2012 Renesas Electronics America Inc. All rights reserved.21
Lab Exercise 1 – Recap (3 of 3)
Hard real time -> Higher priority
Soft real time -> Lower priority
Execution times
Processor utilization
Rate Monotonic Scheduling (RMS)
Unique priority based on the periodic execution rate
The higher periodic execution the higher the priority
Better scheduling of tasks
Not all tasks are periodic
Execution times must be considered
© 2012 Renesas Electronics America Inc. All rights reserved.22
Lab Exercise 2 – Queue Management
© 2012 Renesas Electronics America Inc. All rights reserved.23
Lab Exercise 2 – Queue Management
APIs: xQueueCreate(),
xQueueSendToBack(),
xQueueSendToFront(),
xQueueReceive(),
uxQueueMessagesWaiting()
Communication between tasks
and interrupts
Blocking API call
Not owned by a particular task
Any task can write to a queue
Any task can read from a
queue
Byte by byte copy of the data
Tail
Head
Tail
Head
20
Send
20
Tail
Head
2010
Send
10
Tail
10
Head
Receive
20
© 2012 Renesas Electronics America Inc. All rights reserved.24
Lab Exercise 2 – More on Queues
Use pointers for large data
Pointers queued
Some rules must be followed
Clearly define the owner of
RAM
Avoid simultaneous memory
modifications
Sending task accesses the
memory until pointer is queued
Receiving task accesses the
memory after the pointer is
received from the queue
NO ACCESS IN BETWEEN!
Make sure RAM being pointed
is valid
DO NOT USE STACK!
RAM
Tail
Head
2010
© 2012 Renesas Electronics America Inc. All rights reserved.25
Lab Exercise 2 – You can start the lab now