RTOS & Applications for LPC2148 Aman Arora Ashmita Sinha Karthik Shankar 1 EE382M | Advanced...
-
Upload
silas-gray -
Category
Documents
-
view
217 -
download
0
Transcript of RTOS & Applications for LPC2148 Aman Arora Ashmita Sinha Karthik Shankar 1 EE382M | Advanced...
RTOS & Applications for LPC2148Aman AroraAshmita SinhaKarthik Shankar
1
EE38
2M |
Adv
ance
d Em
bedd
ed S
yste
ms
Arch
itect
ure
Sp
ring
2011
| P
roje
ct P
rese
ntati
on
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
4
LPC 2148 (ARM7)
FreeRTOS
FLASHMUSICLED
CLI
RTOS Selection
Understanding FreeRTOS
Understanding MCB2140 & LPC2148
Porting
CLI & Application Development
Testing & Debugging
Tasks and divisionTask 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, Ashmita5
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
LPC2148
SD Card Slot
Potentiometer
Speaker
LED
COM ports
Reset
USB/Power
11
flash_task(R/W)
Communication(Programming & hyperterminal)
music_task
12led_task (P1:16 –23)
LPC2148
Program Flow
ledTask
CLI Task
flashTask
musicTask
mt
dm
fm
Reset
Startup.s
main
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
LED Port Init
LED Toggle
Delay
LED Clear
LED Task Delete and
Update Task List
LED Task Create
TASK 15
start led stop led
Music Task• Uses both ADC & DAC
• Timer Interrupt period determined based on
POT position (Timer1)
• Registered ISR using VICVectAddr & VICIntEnable
registers
Potentiometer
ADC
Timer Interrupt
Sine Wave Sample
Generation
DAC
Speaker16
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
mmc_write_block(block)MMCWR -> data
MT
FM
DM
EXIT
mmc_write_block(block)mmc_read_block(block)
Compare MMCWR & MMCRD
mmc_read_block(block)MMCRD -> data
Flash Prompt Parse command
18Update Task ListDelete Flash Task
Flash Task APIs
MMC_Init
Send CMD0(Idle State Cmd)
CMD1(SEND_OP_COND)
CMD16(SET_BLOCKLEN)
MMC_Read_Block
Generate Address
corresponding to given block
number
CMD17(READ_SINGLE_BLOCK)
SPI_Receive
MMC_Write_Block
Generate Address
corresponding to given block
number
CMD24(WRITE_SINGLE_BLOCK)SPI_Send
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