Basics of Embedded Systems IAX0230 Click to edit Master title style Course Organisation Prof. Dr. Kalle Tammemäe Prof. Dr.-Ing. Thomas Hollstein Dr. Uljana Reinsalu Goals © Uljana Reinsalu, Thomas Hollstein • The course is intended for Bachelorlevel students to get theoretical and practical knowledge on embedded systems (ES) design and implementation 3 Organization/Contacts • Lecture: Prof. Dr. Kalle Tammemäe [email protected], phone: 620-2260 room: ICT-528 Prof. Dr.-Ing. Thomas Hollstein [email protected], phone: 620-2260 room: ICT-528 © Uljana Reinsalu, Thomas Hollstein Dr. Uljana Reinsalu [email protected], phone: 620-2259 room: ICT-520 • Labs: Siavoosh Payandeh Azad, MSc [email protected], phone: 620-2267 room: ICT-522 Mairo Leier, PhD [email protected], phone: 620-2265 room: ICT-512 Dr. Uljana Reinsalu 4 © Uljana Reinsalu, Thomas Hollstein ES on Moodle Moodle Enrollment Key: 5 Course-internal Communication © Uljana Reinsalu, Thomas Hollstein 1. Moodle: Please update your data in Moodle (with picture – helps to learn the names) 2. E-Mail: [email protected] All your mail’s subjects start with: “ES:” <your subject> Please send today an E-Mail with the following content: FIRST NAME: <e.g. Toomas Hendrik> FAMILY NAME: < e.g. Ilves> STUDENT-ID: <e.g. 08154711 IASM> MOBILE: <your mobile phone number> EMAIL: <your email-address> 6 Course Structure © Uljana Reinsalu, Thomas Hollstein • • • • 5 ECTS 32 hours lectures 32 hours labs 62 hours individual work Reading of course material Planning labs and writing lab reports Preparation for examinations Communication with tutors and other students 7 © Uljana Reinsalu, Thomas Hollstein Lecture Content 1. Pre-course test and Introduction (lecture) 2. Introduction to Microcontrollers 3. Introduction to ARM Cortex-M Processors 4. Microcontroller Input/Output 5. Modular Programming and Debugging 6. Microcontroller programming in C 7. Serial and Parallel Port Interfacing 8. Sensors and Actuators 9. Midsemester exam !!! 10. Interrupt Programming 11. Analog I/O Interfacing 12. HW/SW Synchronization (semaphores?) 13. Low-Power Design of Embedded Systems 14. Time Interfacing 15. Advanced Serial Interfacing (USB, WiFi) 16. Advanced topics 8 Labs © Uljana Reinsalu, Thomas Hollstein Main supported platform: ARM Cortex-M Microcontroller Based System • ARM® Cortex®-M4F Based MCU TM4C123G LaunchPad™ Evaluation Kit Unsupported alternative: TI microcontroller-based Embedded System Design • MSP430F5529 USB LaunchPad Evaluation Kit Lab room: ICT-502A/B Source: TI 9 Assessment Final exam • Labs: 11 labs reported and defended • Mid-term written exam • Final written examination Labs 40% 40% 20% Midterm Exam • Prerequisites for midterm exam: © Uljana Reinsalu, Thomas Hollstein 5 labs for midterm • Prerequisites for final: Midterm exam (positive) 11 labs (= 100%) • Final grade = exam grade – # of missing labs(!) 10 Course book + additional reading © Uljana Reinsalu, Thomas Hollstein • Jonathan W Valvano, Embedded Systems: Introduction to Arm® CortexTM-M Microcontrollers , Fifth Edition (Volume 1) 5th Edition, 2015 (3rd printing), ISBN-10: 1477508996 | ISBN-13: 978-1477508992 http://users.ece.utexas.edu/~valvano/arm/ • Marwedel „Embedded Systems Design“ • Wayne Wolf „Computers as Components. Principles of Embedded Computing System Design“ • Elecia White „Making Embedded Systems“ • Kopetz „Real-Time Systems“ • E. A. Lee, S. A. Seshia „Introducation to Embedded Systems: A cyber-physical systems approach“ 11 Basics of Embedded Systems © Uljana Reinsalu, Thomas Hollstein IAX0230 Introduction Prof. Kalle Tammemäe Prof. Dr.-Ing. Thomas Hollstein Dr. Uljana Reinsalu What is an Embedded System? Definition: Embedded systems (ES) are information processing systems embedded into enclosing products. [Marwedel, 2003] © Uljana Reinsalu, Thomas Hollstein Main reason for buying is not information processing Embedded software is software integrated with physical processes. The technical problem is managing time and concurrency in computational systems. [Lee, 2006] Definition: Cyber-Physical Systems (CPS) are networked integrations of computation and physical processes. 13 © Uljana Reinsalu, Thomas Hollstein Examples of embedded systems • • • • • • • • Cars Avionics House control systems Military Consumer electronics Health care systems Production systems etc. Source: auto123.com Source: www.robotplatform.com Source: retis.sssup.it 14 Example structure of embedded system • • • • Dedicated towards certain application Communicates with environment May have human interface Usually is a part of a bigger system © Uljana Reinsalu, Thomas Hollstein Human interface sensors Network fabric Information processing actuators environment 15 Embedded systems importance © Uljana Reinsalu, Thomas Hollstein 2001 National Research Council Report: “Information technology (IT) is on the verge of another revolution. Driven by the increasing capabilities and ever declining costs of computing and communications devices, IT is being embedded into a growing range of physical devices linked together through networks and will become ever more pervasive as the component technologies become smaller, faster, and cheaper…These networked systems of embedded computers… have the potential to change radically the way people interact with their environment by linking together a range of devices and sensors that will allow information to be collected, shared, and processed in unprecedented ways… The use of [these embedded computers] throughout society could well dwarf previous milestones in the information revolution.” 16 © Uljana Reinsalu, Thomas Hollstein Embedded systems importance • 4 billions of users of mobile phones at 2013, 5 billions at 2019 [statista.com] • 403 million global smartphones sale in fourth quarter of 2015 [gartner.com] • More smart phones are sold worldwide than PCs at 2011 [www.infacts.biz] • Electronics makes more than 25% of todays car price. [EE Times 2010], some high-end cars contain more than 100 processors. • The year profit of home healthcare systems at 2011 is ca. 225 mln. USD (2006 – 70 mln.)[www.itfacts.biz] 17 © Uljana Reinsalu, Thomas Hollstein Examples of embedded systems In Cars: • ABS: anti-lock breaking systems • ESP: electronic stability control • Air bag control systems • Engine control systems • Air condition control systems • Anti-theft protection • Parking assistance • Collision avoidance • Adaptive cruise control, etc. Source: iec.org 18 Examples of embedded systems © Uljana Reinsalu, Thomas Hollstein In Avionics: • Flight control systems • Anti-collision systems • Pilot information systems • Entertainment systems • Others Dependability is of utmost importance Source: retis.sssup.it 19 Examples of embedded systems © Uljana Reinsalu, Thomas Hollstein In Consumer electronics: • MP3 audio • Digital camera • Home electronics: washing machine, microwave etc. • Game consoles Source: www.sciencedirect.com 20 Examples of embedded systems In information systems: • Mobile phones • End-user equipment • Routers and digiboxes • Wireless LAN • others © Uljana Reinsalu, Thomas Hollstein Source: www.ccartoday.com Source: www.techspot.com 21 Examples of embedded systems © Uljana Reinsalu, Thomas Hollstein In fabrication equipment: Controlling the valve Source: P. Marwedel: Embedded System Design 22 Industry 4.0 Source: www.seas.upenn.edu Industry Automation based on Cyber-Physical Systems Control Systems © Uljana Reinsalu, Thomas Hollstein Assembly line Loom 4th Revolution: driven by Networks / cyberspace 3rd Revolution: driven by electronics & computers 2nd Revolution: driven by electrical power 1st Revolution: driven by water & steam power 1784 1870 1970 2000 23 © Uljana Reinsalu, Thomas Hollstein Internet of Things • • Uniquely identifiable objects, having communicating virtual representations in the internet New SmartX services for the convenient organisation of live, work, cities, energy supply, services, … 24 © Uljana Reinsalu, Thomas Hollstein Examples of embedded systems In: • Smart buildings • Robotics • Health care • Logistics • Security • Railways • Military • Etc. 25 Characteristics of embedded systems © Uljana Reinsalu, Thomas Hollstein Must be efficient: 1. Energy efficient 2. Run-time efficient 3. Code size efficient 4. Weight efficient 5. Cost efficient Dedicated towards a certain application. Knowledge about behavior at design time can be used to minimize resources and to maximize robustness Dedicated user-interface: push-buttons, steering wheels, pedals etc. 26 © Uljana Reinsalu, Thomas Hollstein Characteristics of embedded systems (2) Many ES must meet real-time constraints: • A real-time system must react to stimuli from the controlled object (or the operator) within the time interval dictated by the environment. • For real-time systems, right answers arriving too late are wrong • A time-constraint is called hard if not meeting that constraint could result in a catastrophe [Kopetz, 1997] • All other time constraints are soft • A guaranteed system response has to be explained without statistical arguments 27 © Uljana Reinsalu, Thomas Hollstein Characteristics of embedded systems (3) • Frequently connected to the physical environment through sensors, actuators • Many ES are Hybrid systems (analog and digital parts) • Typically, ES are reactive systems A reactive system is one that is in continual interaction with its environment and executes at a pace determined by the environment. [Bergé, 1995] • Behavior depends on input and current state -> automata model is often appropriate 28 © Uljana Reinsalu, Thomas Hollstein Characteristics of embedded systems (4) Must be dependable: 1. Reliability: the probability that a system will not fail 2. Maintainability: probability that a failing system can be repaired within a certain time-frame 3. Availability: probability that the system is available 4. Safety: no harm to be caused 5. Security: confidential and authentic communication 29 Characteristics of embedded systems (5) © Uljana Reinsalu, Thomas Hollstein Even perfectly designed systems can fail if the assumptions about the workload and possible errors turn out to be wrong. [Kopetz, 1997] Making the system dependable must not be an after-thought, it must be considered from the very beginning. [Kopetz, 1997] 30 Challenges in Embedded Systems Design Dynamic environment Must meet real-time constraints Profoundly concurrent How to validate real-time embedded software • HW/SW co-design • Efficient implementation © Uljana Reinsalu, Thomas Hollstein • • • • 31 Iterative design process © Uljana Reinsalu, Thomas Hollstein • Model specify what system does • Design specify how system does what it does • Analysis specify why a system does what is does 32 Simplified design flow application knowledge © Uljana Reinsalu, Thomas Hollstein specification HW-components design repository design application mapping test optimization System software (RTOS, ..) evaluation & validation test 33 © Uljana Reinsalu, Thomas Hollstein Goals • Getting practical experience with embedded microcontrollers (SW programming with close HW relation) • Issues: timing (real-time), I/O handling, power efficiency, dependability 34 What is a Microcontroller??? © Uljana Reinsalu, Thomas Hollstein Microprocessor + RAM + Flash Memory (non-volatile) + Timers + I/O (digital and analog) + Communication (eg. UART, Wireless) 35 Source: Atmel.com MSP430g2553 © Uljana Reinsalu, Thomas Hollstein UART (mini USB) Analog (ADC) inputs Buttons 36 Microcontrol ler GPIO Design Flow/Tool Flow (Code Composer) © Uljana Reinsalu, Thomas Hollstein • Link to TI resourses: http://www.ti.com/ww/en/launchpa d/launchpads-msp430-mspexp430g2.html#tabs 37 © Uljana Reinsalu, Thomas Hollstein How to use Datasheets MSP430 User guide MSP430 datasheet • Functional diagram • Pin description • Description: read thoroughly • Operational modes • Application examples • Concrete section of your current interest 38 Memory-mapped I/O for MSP430 © Uljana Reinsalu, Thomas Hollstein • ...picture The MSP430 von-Neumann architecture has one address space shared with: -SFRs -peripherals -RAM -Flash/ROM memory The addressible memory space is 128 KB 39 Microcontroller Program Structure © Uljana Reinsalu, Thomas Hollstein #include <msp430g2553.h> unsigned int i = 0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer. // P1DIR is a register that configures the direction (DIR) of a port pin as an output or an input. P1DIR |= 0x01; // To set a specific pin as output or input, we write a '1' or '0' on the appropriate bit of the register. // P1DIR = <PIN7><PIN6><PIN5><PIN4><PIN3><PIN2><PIN1><PIN0> // Since we want to blink the on-board red LED, we want to set the direction of Port 1, Pin 0 (P1.0) as an output for (;;) { P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR operation (^=) // P1OUT is another register which holds the status of the LED. // '1' specifies that it's ON or HIGH, while '0' specifies that it's OFF or LOW for(i=0; i< 20000; i++); // Delay between LED toggles. This for-loop will run until the condition is met. } } 40 Labs Overview © Uljana Reinsalu, Thomas Hollstein • 5 introductory labs: 1. Introduction to board and tools; blinking LEDs application 2. Use internal Timers to generate delay; using debugging equipement 3. Using UART; reading inputs with interrups and polling; SPI; I2C 4. Reading processor temperature, generating PWM signal; motor control 5. Power management 41 © Uljana Reinsalu, Thomas Hollstein Achieved Skills • Microcontroller programming using C with close HW relation • Toolchain usage • Design embedded system with off-the-shelf components • Understanding the manuals • Lab equipment usage 42 Basics of Embedded Systems IAX0s30 Click to edit Master title style Basics: Binary Numbers and Operations Prof. Dr. Kalle Tammemäe Dr. Uljana Reinsalu Prof. Dr.-Ing. Thomas Hollstein Microcontrollers: Number Systems • Decimal: Digits 0..9 578 = 5*102 + 7*101 + 8*100 • Binary: © Uljana Reinsalu, Thomas Hollstein Digits 0..1 578D = 512 + 64 + 2 = 0010 0100 0010B • Hexadecimal: Digits 0..F (10D=A, 11D=B,...,15D=F) 578D = 0010 0100 0010B 2 4 2H = 2*162 + 4*161 + 2*160 44 Microcontrollers: Number Systems • Octal: Digits 0..7 578D = 001 001 000 010B 1 1 0 2O © Uljana Reinsalu, Thomas Hollstein = 1*83 +1*82 + 0*81 + 2*80 • Conversion Dec2Hex: 578/16 = 36 36/16 = 2 2/16 = 0 Remainder: 2 Remainder: 4 Remainder: 2 242H 45 Microcontrollers: Arithmetics © Uljana Reinsalu, Thomas Hollstein Subtraction 46 Microcontrollers: 2‘s Complement © Uljana Reinsalu, Thomas Hollstein • 2K: 37D = 127D = 00100101B 11011010B (Bit complement) +1B -------------11011011B = -37D 01111111B 10000000B +1B -------------10000001B = -127D 47 Microcontrollers: 2‘s Complement • 2K: © Uljana Reinsalu, Thomas Hollstein 0D = -128D = Overflow: sign bit changed 00000000B 11111111B (Bit complement) +1B -------------100000000B = 0D 10000000B 01111111B +1B -------------10000000B = -128D 48 © Uljana Reinsalu, Thomas Hollstein Microcontrollers: Signed Arithmetics 49 Microcontrollers: Arithmetics Fixed-point arithmethics: Sign bit 23 22 21 20 2-1 2-2 2-3 © Uljana Reinsalu, Thomas Hollstein Decimal point • After multiplication and division operations normalizing shift operations are required • Multiplications/Divisions can be dangerous, since result could be rounded to 0 50 Setting one Bit in a Control Register • How to set one bit in a Register to 1: © Uljana Reinsalu, Thomas Hollstein Original Register Content: 1 0 1 1 0 1 1 1 Operator: Bitwise OR Bit Mask: 0 0 0 0 1 0 0 0 Final Register Content: 1 0 1 1 1 1 1 1 51 Clearing one Bit in a Control Register • How to set one bit in a Register to 0: Original Register Content: © Uljana Reinsalu, Thomas Hollstein Operator: 1 0 1 1 0 1 1 1 Bitwise AND Bit Mask: 1 1 1 1 1 1 0 1 Final Register Content: 1 0 1 1 0 1 0 1 52 Toggling one Bit in a Control Register • How to toggle an individual bit in a Register: Original Register Content: © Uljana Reinsalu, Thomas Hollstein Operator: 1 0 1 1 0 1 1 1 Bitwise XOR Bit Mask: 0 0 0 1 0 0 0 0 Final Register Content: 1 0 1 0 0 1 1 1 53 Bitwise Clear in a Register © Uljana Reinsalu, Thomas Hollstein • Clearing bits in Register according to control bits: Original Register Content: 1 0 1 1 0 1 1 1 Operator: BIC (bitwise Clear) Control: 1 0 0 1 1 0 1 0 Final Register Content: 0 0 1 0 0 1 0 1 54
© Copyright 2026 Paperzz