Exploring Real-time Microcontroller Architectures for Automotive Systems

microcontrollers n.w
1 / 28
Embed
Share

Delve into the architecture of microcontrollers through a detailed presentation by Mike Holenderski. Learn about Instruction Set Architecture, program execution, communication with external devices, and more. Discover the evolution from hardware to software, the importance of abstraction in fighting complexity, and the practical example of an ECU board. Gain insights into the role of microcontrollers in modern automotive systems and their significance in managing tasks efficiently.

  • Microcontrollers
  • Real-time Architectures
  • Automotive Systems
  • Instruction Set Architecture
  • Program Execution

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Microcontrollers 2IN60: Real-time Architectures (for automotive systems) Mike Holenderski, m.holenderski@tue.nl

  2. Goals for this slide set Describe the architecture of a microcontroller Explain the purpose of an Instruction Set Architecture and what it is Summarize how programs are executed on a microcontroller Describe how programs can communicate with external devices Mike Holenderski, m.holenderski@tue.nl 2

  3. Outline Brief history of microcontrollers Instruction set architecture (ISA) Input and output (I/O) Example Mike Holenderski, m.holenderski@tue.nl 3

  4. Why electronics? Difference Engine No. 2 (1849) Designed by C. Babbage 4000 moving parts 2.6 tons 3m wide, 2m high Easier to move information than physical objects Mike Holenderski, m.holenderski@tue.nl 4

  5. Example ECU (Freescale board EVB9512XF) Power CAN controller CAN port FlexRay port Reset button Digital and Analogue I/O ports Microcontroller (CPU + memory) LEDs Mike Holenderski, m.holenderski@tue.nl 5

  6. From hardware to software Evolution of hardware Vacuum tubes transistors integrated circuits Moore s law: Transistor density doubles every 1.5 years Problem: complexity Large number of applications, performing increasingly complex tasks Can t afford dedicated hardware for individual apps too many apps, large design cost Multiplex several applications on the same hardware Solution: reuse general-purpose components Generic controllers customized with memory (hardware) Memory contains a program (software) Stored-program concept (code + data in memory) Mike Holenderski, m.holenderski@tue.nl 6

  7. Fighting complexity Use abstraction to hide complexity, while keeping the essentials Define an interface to allow using the hardware features without needing to understand all the implementation details Works for hardware and software An interface allows to modify the implementations below and above it independently and transparently Mike Holenderski, m.holenderski@tue.nl 7

  8. Why should I care how a computer works? Understand the limitations of hardware and its abstractions Understand the performance bottlenecks Help write better programs (fewer bugs, more efficient) Critical code still programed in assembly Mike Holenderski, m.holenderski@tue.nl 8

  9. Outline Brief history of microcontrollers Instruction set architecture (ISA) Input and output (I/O) Example Mike Holenderski, m.holenderski@tue.nl 9

  10. Instruction Set Architecture (ISA) CPUs only work with binary signals (bits) Machine instructions: strings of bits telling hardware what to do Machine code: sequence of machine instructions Software Hardware Mike Holenderski, m.holenderski@tue.nl 10

  11. Instruction Set Architecture (ISA) ISA is the interface provided by the hardware to the software Defines the available: instructions registers addressing modes memory architecture interrupt and exception handling external I/O Syntax defined by assembly language Symbolic representation of the machine instructions Examples: x86, ARM, HCS12 Software Hardware Mike Holenderski, m.holenderski@tue.nl 11

  12. Running an application temp = a[0]; a[0] = a[1]; a[1] = temp; High Level Language Program Compiler LDD 6,-SP STD 4,SP LDX 2,SP STX 0,SP STD 2,SP temp = a[0]; Assembly Language Program a[0] = a[1]; a[1] = temp; Assembler 11101100 10101010 01101100 10000100 11101100 10000010 01101100 10000000 01101100 10000010 Machine Language Program Machine Interpretation Control Signal Specification High/Low on control lines Mike Holenderski, m.holenderski@tue.nl 12

  13. Central Processing Unit (CPU) Memory Control Unit Registers ALU CPU Mike Holenderski, m.holenderski@tue.nl 14

  14. Memory Central Processing Unit (CPU) 0 1 Registers 2 CCR 3 PC 4 Memory Memory SP 5 X Y A B 64K -1 D Control Unit Registers Registers Instruction Data1 Data2 ALU ALU CPU ALU Mike Holenderski, m.holenderski@tue.nl 15

  15. Memory 0 1 5 5 Registers Instruction execution 1. Fetch the instruction from memory (pointed to by PC) 2. Fetch the data from memory into internal CPU registers (specified by instruction operands) 3. Execute the instruction 4. Store the results at the proper place (memory or registers) 5. Change PC so that it points to the following instruction 6. Go to step 1 to begin executing the following instruction. 2 CCR 3 ADDA $1 ADDA $1 PC 4 3 4 SP 5 X Y A B 4 4 64K -1 D Instruction Data1 Data2 9 ALU Mike Holenderski, m.holenderski@tue.nl 16

  16. Load-store architecture Load-store architecture Only load and store instructions access the memory, all other instructions use registers as operands. Why not operate directly on memory operands? Accessing memory is slower than CPU registers, so instructions would take longer to execute Freescale HCS12 ISA Arithmetic operators can use register and memory operands E.g. ADDD $20 Add the value at address 20 to the value in register D and store the result in D Memory Registers ALU Mike Holenderski, m.holenderski@tue.nl 17

  17. Assembly instructions (Freescale HCS12) Assembly instruction format: <operation name> <operand1>, <operand2> Examples MOVB $20, PC Move the byte at memory location 20 to PC ADDD $20 Add the two bytes at memory location 20 to register D, and store in D ABA Add the byte in register B to the one in A, and store in A Break larger expressions into multiple instructions LDD b ADDD c SUBD d a = b + c d; (Result a will reside in the D register) Mike Holenderski, m.holenderski@tue.nl 18

  18. Example ISA: Freescale HCS12 C Freescale Registers program counter (PC), stack pointer (SP), condition code register (CCR), accumulators (A,B), index registers (X,Y) Memory local variables global variables Linear array with 64KB Data types int, char, float, unsigned, struct, pointer byte (8b), word (16b) Operators +, -, *, /, %, ++, <, etc. ABA, ADDA, SBA, SUBA, MUL, EDIV, INCA, CMPA, ANDA Memory access a, *a, a[i], a[i][j] LDS, LDAA, LDAB, STS, STAA, STAB, MOVB, MOVW, TFR, PSHA, PULA Control If-then-else, while, procedure call, return BEQ, BLE, BLT, LBEQ, LBLE, LBLT, DBEQ, JMP, JSR, RTS, SWI, RTI Mike Holenderski, m.holenderski@tue.nl 19

  19. Outline Brief history of microcontrollers Instruction set architecture (ISA) Input and output (I/O) Example Mike Holenderski, m.holenderski@tue.nl 20

  20. Input / Output (I/O) Device is a physical thing in the outside world Outside world = outside CPU and memory E.g. a pressure sensor or brake connected via an analogue port, or another ECU connected via CAN port Controller connects device and CPU Electrical conversion and ( intelligent ) control E.g. the CAN controller Interface is an agreement for the connection Physical (plug!), electrical and functional (protocol) Standardized for exchangeability Mike Holenderski, m.holenderski@tue.nl 21

  21. Input / Output (I/O) Program can communicate with external devices by reading and writing data to the input and output ports Digital devices are connected to the digital ports Analogue devices are connected via an Analogue-to-Digital (ATD) converter Converts voltage to a discrete value Each port is mapped to a memory address Some devices need to be setup and controlled by writing to special memory addresses (control registers) Embedded FlexRay and CAN microcontrollers provide higher level communication between several processing boards Mike Holenderski, m.holenderski@tue.nl 22

  22. Outline Brief history of microcontrollers Instruction set architecture (ISA) Input and output (I/O) Example Mike Holenderski, m.holenderski@tue.nl 23

  23. Example: reading a light sensor (Freescale MC9S12XF512) Memory ATDCTL1 ATD CPU PAD14 converter ATDCTL5 ATDSTAT0 ATDDR0 MC9S12XF512 Mike Holenderski, m.holenderski@tue.nl 24

  24. Example: reading a light sensor We want to read the light sensor The light sensor is connected via an ATD converter on the memory mapped I/O port PAD14 We need an ATD driver, providing a method which can be called from a C program, e.g. int light = ATDReadChannel(PAD14); Mike Holenderski, m.holenderski@tue.nl 25

  25. Example: reading a light sensor (Freescale MC9S12XF512) Memory ATDCTL1 ATDCTL5 ATD CPU ATDSTAT0 PAD14 converter ATDDR0 ATDDR15 MC9S12XF512 Mike Holenderski, m.holenderski@tue.nl 26

  26. Example: reading a light sensor (Freescale MC9S12XF512) Implementation of ATDReadChannel(): Conversion parameters (controlled by control registers ATDCTL1 ATDCTL5): Sample resolution (8, 10, or 12 bits) Sample duration (44 2688 cycles) Number of consecutive samples Conversion is started by writing to ATDCTL5 When conversion is finished a bit in status register ATDSTAT0 is set Results are stored in data registers ATDDR0 ATDDR15 Mike Holenderski, m.holenderski@tue.nl 27

  27. Example: reading a light sensor (Freescale MC9S12XF512) MOVB #$10,ATDCTL1 MOVB #$88,ATDCTL3 MOVB #$05,ATDCTL4 MOVB PAD14,ATDCTL5 SCF: BRCLR ATDSTAT0,#$80,SCF BSET ATDSTAT0,#$80 LDX ATDDR0 set A/D resolution to 8 bit set conversion sequence length to 1 set sampling time to 264 cycles set which channel to read wait for the result clear the ATD result flag load the result into register X Mike Holenderski, m.holenderski@tue.nl 28

  28. References D.Patterson and J. Hennessy, Computer Organization & Design , 3rd Edition, 2005 Niklaus Wirth, Algorithms and Data Structures , Prentice-Hall, 1985 Mike Holenderski, m.holenderski@tue.nl 29

Related


More Related Content