Embedded Systems Sivan Toledo Sivan Toledo School of Computer Science Tel Aviv University Tel-Aviv University
Students’ Expectations Students Expectations • Before I start talking, what do you hope to learn?
What is An Embedded System? What is An Embedded System?
What is An Embedded System? What is An Embedded System? • A computer system in a product that is not a computer; a machine, appliance, p ; , pp , satellite, car, etc • The primary objective is not to process or • The primary objective is not to process or present information • Sensing, actuation, control • Fluid boundaries (e g phones) • Fluid boundaries (e.g. phones) • More modern buzzwords: sensor networks, cyber-physical systems, …
Embedded Systems are Different Embedded Systems are Different
Embedded Systems are Different Embedded Systems are Different • Significant per-unit cost (hardware) Si ifi t it t (h d ) – Optimize to use fewer/cheaper parts – Hardware � software Hardware � software • Limited power & cost � limited resources – Memory, CPU power, communications Memory CPU power communications • Real time constraints; can satisfy ms or μ s constraints constraints • Hardware/software co-development – Also, special hardware for debugging/testing Also special hardware for debugging/testing • Hardware fails • Unattended operation & limited or no UI • Unattended operation & limited or no UI
Learning Objectives of the Course Learning Objectives of the Course • Skills to design & implement software for Skill t d i & i l t ft f an embedded system • Ability to understand the documentation and to communicate with hardware designers • Understanding of the deeper issues • Understanding of the deeper issues – Concurrency, failures, timing, power, and more • Not a formal objective but easy to achieve N t f l bj ti b t t hi after the course: build simple systems from scratch t h
More Objectives More Objectives • Life at the extreme bottom of the abstraction hierarchy – Emphasis on low-level drivers • Life in a small community of developers Life in a small community of developers – Few examples, nobody with your hardware – (MCU user groups & vendor support are vibrant) (MCU ser gro ps & endor s pport are ibrant) – But your skills are more valuable • Life with a different type of documentation – Unfamiliar jargon (as in all tech docs) j g ( ) – More complete than software docs
One More One More “I Can Build It”
The Structure of the Course The Structure of the Course • MSc course & BSc workshop together MS & BS k h t th • Lectures Sunday 1-4pm, every week y p , y • Labs Sunday 4-6 (maybe 7), every week • Structured labs in first 7 weeks project in • Structured labs in first 7 weeks, project in last 6 weeks (or optional structured labs) • Projects in pairs (triples only in special ( cases) • We negotiate project proposals • Hard project deadline: April 15 Hard project deadline: April 15
Grades & Projects Grades & Projects • You must attend labs & submit lab reports Y t tt d l b & b it l b t • Each project is different (and hopefully p j ( p y different from previous years’) – Creative software products within the Creative software products within the boundaries of our hardware (or a bit beyond) • Grades based on project (penalty for Grades based on project (penalty for missing labs) – Everybody can do well Everybody can do well – Grade depends on scope & features, difficulty, web presentation and oral presentation web presentation, and oral presentation
Our Hardware 1: LPC2148 Education Board • Microcontroller: LPC2148 by NXP Mi t ll LPC2148 b NXP – ARM7 core, 60MHz, 32-bit, 512KB flash, 40KB RAM, USB device • Character LCD, serial � USB, SD, joystick , , , j y & other switches, pots, LEDs, stepper, temp sensor, buzzer p , • We have ethernet cards, prototyping cards • Programming through serial � USB • Programming through serial � USB • We do not use an operating system • We do not have hardware debugger
Our Hardware 2: Telos B (T-mote sky) • Microcontroller: MSP430F1611 by TI – 8MHz, 16-bit, 48KB Flash, 10KB RAM, low- , , , , power • Serial � USB bridge (also for programming) • Serial � USB bridge (also for programming) • 802.15.4 radio transceiver (low-power data) • Light, temperature & humidity sensors • Used in sensor networking research • Used in sensor-networking research • “OS”: Contiki (also TinyOS, or no OS) • No hardware debugger
More Hardware We Have More Hardware We Have • Platforms: AVR Butterfly, other LPC boards (CAN), more MSP430 boards, PIC boards ( ), , • Some with debuggers • More low-power RF transceivers (cc1101) M l RF t i ( 1101) • Wifi boards for embedded systems boa ds o e bedded syste s (designed for PICs, probably usable with other MCUs) other MCUs) • Android phones coming in (more later) • Electronic construction & test equipment
Backend Software (& Android) Backend Software (& Android) • Some projects are embedded software only • Some need backend software • In previous years backend software was I i b k d ft all Linux and/or Windows • This year we can do projects whose backend software runs on an android backend software runs on an android phone!
2009/2010 Projects 2009/2010 Projects • • USB Ethernet Adapter for Windows (RNDIS) USB Ethernet Adapter for Windows (RNDIS) • USB HID host-side Perl libraries • Live Storage Device • LUA programming language on the LPC2148 • IR Remote Proxy using a PIC18F2550 y g • Porting Contiki to the LPC2148 Education Board • Network-attached storage • Home automation using XBee modules • TFTP server over USB (uIP over CDC-ECM) • Virtual USB Ethernet adapter for LPC2148 (CDC-ECM) • A JTAG Pod • Infrared USB Keyboard • Sync: disk-on-key synchronization to Dropbox with the mbed system • • USB to I2C and to GPIO Bridge USB to I2C and to GPIO Bridge • An MP3 Music Player • CC2420 on FreeRTOS • GDB for the LPC2148 • Transmitting high-speed ADC samples through UIP (IP over USB) g g p p g ( ) • A USB bootloader for for the LPC2148 • A CAN OBD Emulator • EthVPN: Ethernet-virtualizing VPN device • I-Feel: temperature sensor and infrared controller for an air conditioner
BASICS BASICS
Mechanics Mechanics assembler assembler assembler assembler startup.S (as) (as) linker linker (ld) (ld) cross cross assembler assembler prog.c prog.elf compiler (gcc) compiler (gcc) (as) (as) mcu.h image image converter converter converter converter prog.hex PC PC downloader downloader (lpc21isp,…) (lpc21isp,…) USB � USB � serial i l programming programming g g i g i g JTAG, proprietary hardware hardware special special hardware h h hardware d d micro- micro- controller controller
MCUs MCUs Block diagram of diagram of the LPC2148
Microcontrollers: Block Diagram of the MSP430F1611
MCUs MCUs Block diagram of diagram of the LPC2148
Building a simple program: Blinking an LED
Building a simple program: Blinking an LED Pin P0 10 is a digital I/O Pin P0.10 is a digital I/O Logic high � 3.3V (MCU supply) Logic low � 0V (ground) Logic low � 0V (ground) How do we toggle P0 10? How do we toggle P0.10?
Toggling a Digital Output Toggling a Digital Output • Consult reference (user) manual C lt f ( ) l • Go to General Purpose I/O (GPIO) • Manual describes how special function registers (SFRs) interact with the hardware ( ) • IO0DIR controls direction (input/output) • Symbolic name for address 0xE0028008 • Symbolic name for address 0xE0028008 • IO0PIN controls/shows pin state (high/low) • Header file defines symbolic names for SFRs: H d fil d fi b li f SFR #define IOPIN0 (*(volatile unsigned long*)(0xE0028008)) d fi (*( l il i d l *)( ))
The Program The Program #include <lpc2000/io.h> volatile int dummy; const int delay = 100000; t i t d l 100000 void main(void) { int i; int i; IODIR0 = BIT10; // BIT10==0b00..010000000000 while (1) { for (i=0; i<delay; y++) dummy=1; IOPIN0 |= BIT10; IOPIN0 |= BIT10; for (i=0; i<delay; y++) dummy=1; IOPIN0 &= ~BIT10; } }
The Program The Program #include <lpc2000/io.h> why volatile? why volatile? volatile int dummy; const int delay = 100000; t i t d l 100000 SFR is used like a variable (at a void main(void) { fixed address) ) int i; int i; IODIR0 = BIT10; // BIT10==0b00..010000000000 delay loop while (1) { for (i=0; i<delay; y++) dummy=1; IOPIN0 |= BIT10; IOPIN0 |= BIT10; for (i=0; i<delay; y++) dummy=1; IOPIN0 &= ~BIT10; on or off? } } }
What Happens Before Main ? What Happens Before Main ?
Recommend
More recommend