presentation

advertisement
Aman Arora
Ashmita Sinha
Karthik Shankar
EE382M | Advanced Embedded Systems Architecture
Spring 2011 | Project Presentation
RTOS & Applications
for LPC2148
1
Agenda
•
•
•
•
•
•
•
•
Objective
Overview
FreeRTOS
Porting
MCB2140 & LPC2148
CLI & Applications
Results and Status
Demo
2
Objective
• To port an RTOS on LPC2148
• ARM7 based SOC from NXP
• Development board - MCB2140 from KEIL
• To develop applications on top of the RTOS
• Most importantly, LEARN !!!
3
Overview
RTOS Selection
Understanding
FreeRTOS
Understanding
MCB2140 & LPC2148
Porting
CLI & Application
Development
Testing & Debugging
LED
MUSIC
FLASH
CLI
FreeRTOS
LPC 2148 (ARM7)
4
Tasks and division
Task
Who?
Choosing a RTOS
Aman, Karthik, Ashmita
Understanding the board and the
SOC
Aman, Karthik, Ashmita
Understanding the concepts of
FreeRTOS
Aman, Karthik, Ashmita
Porting the RTOS and writing the
LED Task
Karthik, Ashmita
The Music Task
Aman, Karthik
The Flash Task
Aman, Karthik
Command Line Interface
Aman, Ashmita
Porting FatFS
Karthik, Ashmita
5
FreeRTOS
• Why FreeRTOS?
•
•
•
•
Free!
Active project
Low footprint – 4K to 7K
Good documentation
• Features
•
•
•
•
•
•
Written mostly in C
Supports tasks and co-routines
Many communication and synchronization primitives
Version 6.1.1
Mini-real time kernel
freeRTOSConfig.h
6
FreeRTOS
• Scheduler
• Supports preemptive, cooperative or hybrid scheduling
• Threads are maintained in a queue
• Scheduling algorithm – highest priority first
• Threads which are runnable and have highest priority are scheduled
• Threads with same priority run with round robin scheduling
• Preemption implemented
• Tick count – Tasks can mention the max time to be blocked
• Will be waken up after the time
7
FreeRTOS
• Tasks
• Running, Ready, Blocked or Suspended state
• Task priority – 0 to (configMAX_PRIORITIES - 1)
• 0 – lowest
• APIs
• xTaskCreate, vTaskResume, vTaskSuspend, xTaskHandle, vTaskDelete
• Idle task – priority 0
• Idle task hook (called during each cycle of idle task)
• Co-routines
• Only intended for very small processors with severe RAM
constraints
• Shared stack
• Complex
8
FreeRTOS
• Inter process communication
• Queues
• Passed by value
• Blocking or Non-Blocking
• Zero time out creates non-blocking
• Used in ISRs
• Mutex
• With priority inversion
• Semaphore
9
Porting
• Used FreeRTOS for LPC2888 as reference
• Existing port used Rowley-GCC compiler
• Modified Startup.s
• Reduced stack size for FIQ
• Kept the same values for PLL
• Removed EMC configurations
• Modified SOC specific register addresses (LPC214x.h)
• Removed extra hardware configurations from prvSetupHardware
function (like I2S, USB, etc.)
• Modified compiler dependent ISR definitions
• Redid project files/makefiles for Keil uVision
• Reduced the functionalities in the RTOS due to compiler limitations
• Removed the ErrorChecking task
• Enabled vTaskDelete
10
MCB2140
Speaker
LED
Reset
SD Card Slot
Potentiometer
LPC2148
USB/Power
11
COM ports
LPC2148
music_task
flash_task(R/W)
Communication(Pr
ogramming &
hyperterminal)
led_task
(P1:16 –23)
12
Program Flow
Reset
Startup.s
ledTask
main
CLI Task
mt
flashTask
dm
musicTask
fm
13
Command Line Interface
• Interface to the user through COM port
• Some commands implemented
•
•
•
•
•
TOP
CLEAR
START LED
STOP LED
START FLASH
• MT
• FM
• DM
•
•
•
•
STOP FLASH
START MUSIC
STOP MUSIC
ECHO
14
LED Task
• Mainly used for debugging purpose
• LEDs mapped to P1.16 -> P1.23 implement 8 bit counter
start led
LED Task
Create
stop led
LED Port
Init
LED
Toggle
LED Clear
LED Task
Delete and
Update Task
List
Delay
TASK
15
Music Task
• Uses both ADC & DAC
• Timer Interrupt period
determined based on
POT position (Timer1)
• Registered ISR using
VICVectAddr &
VICIntEnable
registers
Potentiometer
ADC
Sine Wave
Sample
Generation
Timer
Interrupt
DAC
Speaker
16
Flash Task
• Used APIs for SPI and MMC communication (Source: NXP)
• Modified hardware specific initializations (Init function)
• CLK freq
• Block /Sector Configuration
• Changed bare metal calls to RTOS level calls
• Resolved conflicts in register addresses
17
Flash Task
Flash Prompt
MT
mmc_write_block(block)
mmc_read_block(block)
Compare MMCWR &
MMCRD
FM
mmc_write_block(block)
MMCWR -> data
DM
mmc_read_block(block)
MMCRD -> data
EXIT
Update Task List
Delete Flash Task
Parse
command
18
Flash Task APIs
MMC_Init
Send CMD0(Idle
State Cmd)
CMD1(SEND_OP_C
OND)
CMD16(SET_BLOC
KLEN)
MMC_Write_Block
Generate
Address
corresponding
to given block
number
CMD24(WRITE_SINGLE
_BLOCK)
SPI_Send
MMC_Read_Block
Generate
Address
corresponding
to given block
number
CMD17(READ_SINGLE_
BLOCK)
SPI_Receive
19
FatFS
• Generic FAT filesystem module for small embedded systems
• Provides application interface (fopen, fclose, fmount) and disk
• I/O interface (disk initialize, disk read/write)
• Found existing implementation for OLIMEX ARM7 board
• Issues faced:
• Port was for MMC interface - had different pinout
• Unable to initialize disk
• Compiler Issues
20
Results and Status
• Successfully ported FreeRTOS on LPC2148
• Created Command Line Interface through UART
• Successfully developed/ported applications
• LED
• Music
• Flash
• Block read and write only
• Struggling with FatFS porting
21
Next Time…
• Port a more complex Operating System
• Start early on FatFS port!!!
• Add USB interface to SD card
22
References
•
•
•
•
•
http://www.freertos.org/
http://www.keil.com/mcb2140/
LPC2148 user manual
http://efsl.be/
http://ics.nxp.com/support/documents/microcontrollers/pdf/
an10406.pdf
23
DEMO …
24
Download