Upload
razvymed
View
83
Download
0
Tags:
Embed Size (px)
Citation preview
Embedded Systems
Lucian Blaga University Sibiu Electromechanical EngineeringDr. Houman Amjadi
Targets and Contents
Introduction
Embedded Operating Systems
Definition and Requirements Application Area Importance of Embedded Systems
Definition Execution Times Scheduling in Real-Time Systems
Embedded Systems Hardware
Hardware/Software Codesign
Introduction Inputs Communication Processing Units Memories Outputs
System Initilaization Partioning
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
2
Definition
Embedded System are systems consisting of hardware and software components, which are built into and tightly couples with a surrounding technical environment. Example: Mobile phones, consumer electronics, fab/process control units, transportation systems etc. Embedded systems
are Information processing systems. are Integrated into a larger environmental system. execute dedicated control tasks within the entire system. interact with the environment through sensors (inputs) and actuators (outputs). Have dedicated user interfaces like push buttons, steering wheels etc.
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
3
Requirements
Embedded System have to be dependable. Following aspects must be given:
Reliability: The probability that a system will not fail. Maintainability: The probability that a failing system can be repaired within a certain time-frame. Availability: The probability that a system is available. Safety: A failing system shall not cause any harm. Security: Confidential data shall remain confidential and authentic communication shall be guaranteed,. Energy: Optimizing usage of electrical energy Code-size: Especially true for a system on chip (SoC) Run-time: The minimum amount of resources shall be used for implementation of the functionality. Weight: All portable systems must be of low weight. Cost: Efficient usage of hardware components and software development budget keep prices low and ensure competitiveness on the market.
Embedded systems have to be efficient.
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
4
Time Constraints
Most embedded systems must complete computation within a given time-frame. Violation of this constraint may result in loss of data or cause harm to user. A time constraint is called hard if not meeting that constraint will result in a catastrophe. All other constraints are called soft. Improvement of information processing time.
Sometimes in contradiction with requirements regarding power consumption, cost etc.
For embedded systems with hard time-constraint, the guaranteed system response time must be described without statistical arguments.
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
5
Classification of Digital Systems
Digital information processing systems can be classified into three categories: transformational, interactive and reactive systems. Transformational systems: all system inputs must be available, before data processing and calculation of output values starts. Outputs are available only upon completion of the data processing steps. User or environment can not take influence on a running process. Interactive systems synchronize continuously their inputs with the environment. The interaction is triggered by the control system, but the user or the environment. New data is requested by the system. In case of reactive systems, the control unit reacts on external stimuli. Synchronization is done by the environment or by the user.
Embedded systems are typically reactive.
Mainly due to requirements regarding high reliability and proven response times.
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
6
Application Areas
Automotive Electronics
Safety critical control systems like ABS, airbag Comfort functions like window lifters, climate conditioning Infotainment like navigation, radio system Safety critical systems like anti-collision systems, pilot information systems Comfort functions, Infotainment
Avionics
Telecommunications: Mobile phones with additional functionalities Authentication Systems: Advanced payment systems Consumer Electronics: Video and audio systems Fabrication equipment
Safety, Energy consumption, etc. Reduction of energy consumption Increasing comfort level Improve safety and security
Smart buildings
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
7
Importance of Embedded Systems
Example of a high-end car A major portion of innovation in automotive field is already due to electronics. Growing field due to environmental requirements, increasing safety, increasing infotainment
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
8
Architecture of an Embedded System
Despite high variety of application areas, logical structure of embedded systems is very similar. Basic components of an ES are:
Control Unit Actuators and Sensors User interface Environment User User Interface Control UnitActuating Variable
Process Parameters
Communication channels are shown as arrows.
Actuators
Sensors
Signals or information flowAccess Measurement
User Environment
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
9
Control Unit
Heart of the embedded system is the control unit.
Generate reaction to the system based on inputs from environment and user inputs
Implemented mainly as programmable system, consisting of hardware and software Main forms of control unit are:Device Microcontroller DSP ASIP FPGA PLD ASIC Cost Digital Signal Processor Application Specific Instruction Set Processor Field Programmable Gate Array Programmable Logic Device Application Specific Integrated Circuit Definition Main Features Embedded memory and peripherals Support for complex arithmetic operations, parallel instructions, floating point and fixed point instructions Dedicated and specilaized instruction set for the given control task, optimized memopry architecture Definition of function by programmable switches. Design based on application requirements Flexibility
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
10
Interface to Analog World
Information flow from Environment to control unit:
Sensor: Converts a physical input signal (temperature, pressure, light etc.) into an electrical signal. Signal Conditioning: Offset compensation, scaling, etc. Analog-to-Digital converters (ADC) The elements can be combined into a single unit, the so-called smart sensor.
Taking control over the environment by the control unit
Connection between information processing unit and the process Digital interface of the control unit Digital-to-Analog converters (DAC) Actuator: Electrical input (current, pulse) is converted into mechanical energy.
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
11
Inside the Microcontroller 1/3
Processor Core
Main criteria for the core is, to provide enough processing power to perform the tasks within the system. Realistic estimation of size and complexity of tasks Benchmarks: Measurement of system performance Also important factors are cost, power consumption, software tools, availability etc. Storage for the software (application code) to be executed Non-volatile memory: Content is retained even after power is removed. On-chip (embedded memory) or external EEPROM Often made out of flash: High density memory, electrically programmable/erasable
Core
Memory
Memory
RAM
Application code can be modified if necessary.
Alternatively, Read Only Memory (ROM) can be used due to lower cost.
System Modules
Peripherals
Code is programmed into the device during production and can not be changed.Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi 12
25.01.2010
Inside the Microcontroller 2/3
Random Access Memory
Storage of data such as program variables, intermediate results, status information and others Needed by software to store variables and manage software structures such as stack Very short access times are mandatory to improve data throughput. Amount of RAM is usually much smaller than main memory. Support for operation of the microcontroller Oscillator / PLL: Generation of internal timebase for all modules Interrupt Controller: Gathering and priorization of service requests by peripheral modules Peripheral Bridge: Transfer high-speed accesses of the core to the low-speed peripheral modules Watchdog: Supervision of processor operation, detection of deadlock condition
Core
Memory
System Modules
RAM
System Modules
Peripherals
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
13
Inside the Microcontroller 3/3
Peripheral Modules
Binary Interfaces: Ports
Simple external pins whose logic state can be controlled by the processor Can be sued individually or grouped together to create parallel ports. A set of input or output bits can be accessed simultaneously. Send or receive data using same pin or separate pins as input and output A register is used to transfer data between processor core and the device pin. Additional bits might be added to the data stream as defined by the protocol. Capture: Measure time between events at a device pin PWM/Compare: Change status of a device pin based on defined time slots
Core
Memory
Serial Interfaces: SPI, SCI, CAN, FlexRay
RAM
Time Derived Outputs: PWM
System Modules
Peripherals
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
14
Example: PIC30F6010
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadiwww.microchip.com
15
PIC Family of Microcontrollers
www.microchip.com
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
16
Example of a Control System: Thermal Chamber
LCD
Buzzer
Heater Oven Microcontroller Fan Sensor PC Interface
Keyboard25.01.2010 Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi 17
DsPIC30F6010: Features
16-bit RISC CPU
Harvard architecture 84 base instructions 16 x 16 bit register array Up to 30 MIPs @ 120 MHz 144 kB on-chip flash memory space, 8 kB on-chip data RAM High-current source/sink I/O pins: 25 mA / 25 mA 2 3-wire SPI modules, 2 UART modules, 2 CAN modules, I2C module Timer module with programmable prescaler: 5 x 16-bit timers/counters 2.5 V to 5.5 V supply voltage -40 C to 125 C DC to 40 MHz external clock input 4 MHz to 10 MHz oscillator input with PLL active (4x, 8x, 16x)Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi 18
On-Chip Memory
Peripherals
Wide Operation Range
25.01.2010
DsPIC30F6010: Reset
Starting up system from a known state Code execution starts at address 0.
Supervising the power supply: Power-On reset POR and Brown-Out reset External reset request: MCLR pin Supervising program execution: Watchdog timer, Detection of critical conditions during code execution:
Reset caused by trap lockup (TRAPR) or illegal opcode
Intended by application code: RESET instruction
www.microchip.com
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
19
DsPIC30F6010: Clock Circuitry
All microcontrollers require a clock to operate. Usually provided by external timing devices to the microcontroller Quartz crystal and some supporting circuitry used for high timing precision Instruction cycle:
fetching from memory, decoding, execution Can take several clock periods
System clock is generated from quartz frequency by means of Phased Lock Loop circuitry (PLL) Flexibility to adjust system frequency to application requirements
Device performance, current consumption, EMC, etc.
Quartz Frequency [MHz] 4 - 10 4 - 10 4 - 7.525.01.2010
PLL Multiplier x4 x8 x16
System Frequency [MHz] 16 - 40 32 - 80 64 12020
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
DsPIC30F6010: I/O Ports
I/O pins can be grouped together to build an I/O port. All port pins have three registers directly associated with the operation of the port pins.
Data Direction Register TRISx Data Output Register LATx Pin Status Register PORTx
After reset, all pins are in input mode (TRISx = 0xff) I/O as output:
Write pin state to LATx Set TRISx to 0 (output) Check result by comparing LATx to PORTx
I/O as input:
Set TRISx to 1 (input) Read pin value through PORTxEmbedded Systems / Lucian Blaga University / Dr. Houman Amjadi
www.microchip.com
25.01.2010
21
DsPIC30F6010: Output Port CircuitriesCurrent Sourcing
Current Sinking
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
22
DsPIC30F6010: Driving LEDs via Output Port
Light Emitting Diodes (LED) come in many different sizes, shapes and colors. Different values for current consumption:
A few mA for small LEDs About 10 mA for standard LEDs 10 to 25 mA for very bright LEDs
The voltage drop across the LED is about 2 V. Voltage at the output of the microcontroller is about 5 V.
LED can not be directly connected to the I/O pin! Current must be limited by a resistor.
Assumptions:
Voltage of port = 5 V Voltage drop across LED = 2 V Current through LED = 10 mA Next physical resistor value: 330 Ohm
R=
U 52 V = =0.3 kOhm I 10 mA
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
23
DsPIC30F6010: Input Port Circuitries
In input mode, state of the I/O pins is changed by external events. Example: push-button, input from another microcontroller, sensor signal etc. Pull-up or pull-down resistors are used to define the state of the pin when the button is open. Current into the I/O pin must be limited. Status of the I/O must be checked by application code (PORTx register). Current into the I/O pin is called leakage current.
Active Low
0.01 uA typ., 1 uA max. Active High 50 pF max. Highest voltage detected as 0, 0.2 x VDD Lowest voltage detected as 1, 0.8 x VDD
Input capacitance has also to be considered.
Input Low Voltage VIL
Input High Voltage VIH
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
24
DsPIC30F6010: Serial Interfaces - UART
Universal Asynchronous Receiver Transmitter UART Full-duplex, 8-bit or 9-bit data transmission
Transmitter Block Diagram
Dedicated transmit and receive pins Single-wire communication is also possible.
Even, odd or no parity One or two stop bits Baud rate generator with 16-bit prescalerwww.microchip.com
Baud rate range from 38 bps to 1.875 Mbps @ 30 Mhz system frequency
Receiver Block Diagram
4-word deep transmit and receive data buffers Parity, framing and buffer overrun error flags Separate transmit and receive interrupts Same protocol must be defined for both communication partners
25.01.2010
www.microchip.com Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
25
DsPIC30F6010: Serial Interfaces - SPI
Serial Peripheral Interface is a synchronous data transfer interface. Generally used for high speed data transfer on short distances (same PCB) 16-bit shift register for receiving and transmitting data 16-bit buffer register Two prescalers (2 bit and 3 bit) to generate transfer clock out of input to module (system frequency / 4) Serial interface consists of 4 pins: www.microchip.com
Separate data input and output pins Shift clock pin (input or output) Slave select pin Data Transfer In Master Modewww.microchip.com
Adjustable data transfer size: 8 or 16 bit Master mode: Clock is generated out of system frequency, data written to transmit buffer is sent out immediately. Slave mode: Data transmission is activated if SS pin is pulled low. Serial clock is configured as input.
Data Transfer In Slave Mode26www.microchip.com
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
DsPIC30F6010: Serial Interfaces - CAN
Controller Area Network (CAN) is a serial interface. Used widely in automotive and industrial applications
Several failure avoiding and detection features for improved robustness
Standard and extended data frames 0 to 8 data bytes Programmable bit rates up to 1 Mbaud Acceptance filters to limit amount of received data Interrupts for all CAN receive and transmit errors Time stamp generation 5 different types of errors are recognized by the CAN state machine:
Bit error: Value of sent bit is different from received value. Stuff error: 6 consecutive bits have the same value. CRC error: Calculated CRC value by receiver does not match the transmitted value. Form error: Fix-form bit field contains invalid bit value. Acknowledgment error: Acknowledge slot does not contain dominant value.
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
27
DsPIC30F6010: Serial Interfaces CAN Block Diagram
www.microchip.com
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
28
DsPIC30F6010: Serial Interfaces CAN Data Formats
Standard Data Format
Extended Data Format
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
29
DsPIC30F6010: Serial Interfaces - ComparisonFeature Transfer Form Data Exchange SCI Asynchronous Duplex SPI Synchronous. Simultaneous transfer and receive CAN Asynchronous. Unidirectional
ArbitrationTransfer Rate Pin Count Physical Layer
By application SW57 kBaud 2 pin or single-wire RS232: 15 V / -15 V ISO-K: 12 V
Master-Slave definition10 MBaud 4 pins and more 3.3 V or 5 V
Handled by HW1 MBaud 2 pins 2.5 V as steady state High state: + 1 V for CAN-H -1 V for CAN-L HW support for bit timing, CRC
Failure Detection
Parity (optional)
By application SW
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
30
DsPIC30F6010: Time Driven Interfaces - IC
Input Capture Modules used for measuring frequency and pulse duration Generation of interrupts based on event on pin Capture for:
Every falling edge Every rising edge Every 4 rising edge Every 16. rising edge Every falling and rising edge
Selectable clock reference
www.microchip.com
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
31
DsPIC30F6010: Time Driven Interfaces - OC
Output Compare Modules used for generation of variable width output pulses Generation of interrupts on Output Compare or PWM event Operation modes:
Single OC match mode: Change pin state after a given time Dual OC match mode: Set and clear pin state after defined times Simple PWM mode: Generate PWM pulse with given pulse width and period
Selectable clock reference
www.microchip.com
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
32
Definition of RTOS
An Operating System OS is the interface between the hardware and user.
Responsible for management and coordination of tasks Sharing resources of hardware between tasks Supervising resource usage and handling access protection
RTOS = Real Time Operating System
OS running in an embedded system Requirements regarding real-time are considered and fulfilled. System response to an application request is highly consistent and predictable. Real-time requirement is the main design goal, not the system performance!
OSEK = Offene Systeme und deren Schnittstellen fuer die Elektronik in Kraftfahrzeugen
Open Systems and their Interfaces for the Electronics in Motor Vehicles Open standard for OSEK implementation in automotive area Founded in 1993, followed up by AutoSAR OSEmbedded Systems / Lucian Blaga University / Dr. Houman Amjadi 33
25.01.2010
interfaces of RTOS
Application software is the entire software running in an embedded system. Single modules include control algorithm for the embedded device, graphical user interface, diagnostics tools, system self-test routines, etc.
Application Module 1 Module 2 Module n API IO System LLD
Application software accesses resources of the operating system by means of Application Programming Interfaces API.
API OSEK LLD
Also referred to as system calls
Accesses of the OSEK to the microcontroller resources are handled by Low Level Drivers LLD.
Also referred to as Microcontroller Abstraction Level MCAL
Embedded Hardware Microcontroller)
Simplification of software design (modules) by unified and specified interfacesEmbedded Systems / Lucian Blaga University / Dr. Houman Amjadi 34
25.01.2010
Definition of Tasks
Tasks form the logical unit of computation in a processor. Each module consists of several tasks which are executed during run-time. Tasks are characterized by the following parameters and properties:
Name (numerical ID): Identifier for the task Priority: Which task shall be executed first, if several ones are requesting for execution? Preemptive / Non-Preemptive scheduling: Can the task be interrupted in case of requests from a task with higher priority? Activation cycle: How often and in which frequency shall the task be executed? Deadline: Maximum time required for execution and completion of the task Required stack size: RAM memory which is needed for this dedicated task Hooks
PreTaskHook(): OS activities to prepare for the task execution PostTakHook(): OS activities upon completion of a task
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
35
Preemptive Task Scheduling
Preemptive task scheduling: The running task can be interrupted at any point. Activation of a task with higher priority will automatically abort the execution of the currently running task.Activation of Task 2 (Higher Prio. Than Task 1) Termination of Task 2
Task 1
running
ready
running
Task 2
suspended
ready
running
suspended
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
36
Non-Preemptive Task Scheduling
Non-Preemptive task scheduling: Task switch occurs only at defined points in time.
OS scheduler is called (checkpoint), The running task has terminated and the OS can kick off the next task, A running task is waiting for an external event and can not continue execution.
A low priority task will not be interrupted until the next checkpoint has reached.
Latency time for execution of a higher priority task must be taken into acount!Activation of Task 2 (Higher Prio. Than Task 1)
Termination of Task 1
Task 1 suspended
running
suspended
Task 2
readyLatency Time for Task 2
running
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
37
Definition of Hooks
Hooks are elementary functions of an OSEK. By means of hooks, user can execute specific activities at given points in execution of an operating system.
During startup of the system: StartOS Before and after execution of a dedicated task: PreTaskHook, PostTaskHook In case of an error: ErrorHook While turning off the system: ShutdownHook
They have higher priority than all tasks and envelope a running task. Hooks must be implemented by the user, depending on the required activity.
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
38
PreTaskHook / PostTaskHook
Preparing execution of a task is handled by PreTaskHooks: Assignment of required resources to the task, start on runtime supervision, etc. Upon termination of a task, PostTaskHook releases resources used by the running task. Also, status of the completed task can be evaluated. These hooks can also be used for debugging a task.
Resources used by the task can be supervised and tracked.
PostTaskHook(2)
OS Internal Activities
PreTaskHook(1)
Task 1 running
ready
running
Task 2
suspended
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
39
StartOS / ShutdownOS
After starting up the system and before starting the task scheduling, StartOS is executed.
Can be used for initialization of the system or running self-checks. Interrupts are disabled at this point. Application tasks are not started yet.
When system shall be shutdown, ShutdownOS is called.
Severe system failure (fatal error) or user request Possible activities implemented in ShutdownOS are storage of error codes or total runtime of system.
OS initialization
System selfcheck
Storage of debug information
Hardware specific startup code (Bootcode)25.01.2010
Call to StartOS
OC kernel is running
Tasks
Tasks
Call to ShutdownOS40
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
Scheduling of Tasks
Each task has a dedicated priority. At any given point in time, all tasks in running or ready state build a queue.
Tasks of same level are treated often as FIFO: First-In, First-Out At a system checkpoint, the scheduler scans for the next task to be executed. Among all queues with entires, the one with highest priority is selected. Within this queue, the task with the longest waiting time (First-In) is selected. low 0
This task is planned for processing and execution. high n FIFO Queue Task n-1 2 1
Priority Lowest Waiting time Highest Waiting time
Scheduler Task to be executed as next: In queue with highest priority with longest waiting time25.01.2010 Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi 41
Initialization of Embedded SystemPhase Power-Up Operation Power supply is turned on. Oscillator circuitry starts up and locks. External modules (sensors, actuators) are turned on. Basic Initialization of microcontroller Comments System is kept in reset state, i.e. it dos not take control over the environment. Elementary modules of microcontroller (core, RAM, memory interface) are set up to operate correctly. System starts up in normal operation mode if all tests pass. Setting up target system frequency, interrupt system, transfer rates of interface modules etc. In case of detected issues, system may start in a failsafe mode with reduced functionality and enhanced diagnostics possibilities. Time constraints regarding turning off the power supply must be considered!42
Initialization
Self-Check
Re-Initialization
Testing internal modules of microcontroller Checking interfaces to environment (sensors and actuators) Initialization of module based on target application Starting up operating system and/or main control application
Operation
Shutdown
25.01.2010
Modules of application are stopped. HW interfaces are turned off and do not take control over system or exchange information any more. Embedded Systems / Power supply can be turned off. Lucian Blaga University / Dr. Houman Amjadi
HW Specific Startup Code 1/2
Initialization of the embedded system starts with Microcontroller. System has to start from a known state. Following steps followed be executed in order of execution: 1. Core: Not all core registers have a defined reset value. Hence, they must be set to a known start value. 2. RAM: After reset, content of RAM is not defined. Prior to read accesses to RAM (variables, stack, etc.), content of the utilized RAM memory shall be written to a defined start value. 3. Main Memory: Response of main memory to core access requests is much slower than of RAM. So-called wait states must be defined. These add delay to response by main memory until data for core is available. Number of WS depends of target frequency. Also, features like page buffers must be adjusted. 4. PLL: At this point, the target system frequency shall be set . 5. Watchdog Timer: If this feature is not used in the application, it shall be turned off. 6. Other System Modules: Including interrupt controller and timer module for generation of the synchronization time stamps
1: Core
3: Memory
2: RAM
4: System Modules
5: Peripherals43
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
HW Specific Startup Code 2/2
Upon completion of the basic microcontroller initialization, peripheral modules can be set up.
Setting up ports as input or output with defined initial values Setting up protocol and baud rate for serial interfaces like SPI, SCI, CAN Setting up and configuration of timer-based interfaces IC, OC, PWM etc.
Prior to start of the control code, it is recommended to verify the proper operation of key system components. Both correct operation of the system modules (positive test) as well as expected system response to detected issues (negative tests) shall be considered.
Examples for Positive Tests:
Verification of expected contents for memories Data exchange via interfaces and verification of expected return values Transmission of wrong data to a slave device and checking for expected response Violation of timing (deadtimes) and verification of proper system response
Examples for Negative Tests:
Due to the executed self tests, configuration of some modules might need corrected. Reinitialization Switch to normal operation (starting OSEK and control code) can now follow.
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
44
Languages for Source Code
An embedded system has limited resources regarding main memory and RAM. Performance of the system can be optimized up to a given level by increasing the system frequency. Response time of the system to inputs from the environment and taking corrective actions has to be kept as low as possible. It is mandatory to access and manipulate deep system resources like core registers. On the other side, maintenance of system must be given. In case of SW, ease of readability is a key parameter. The ability to transfer code from one microcontroller family to another one in short time is another important factor in SW development in embedded area. While Assembly is the best choice regarding performance, ease of handling and flexibility is given by high-level languages like C. Portions of code may be programmed in one or other language based on the dedicated requirements. Optimized source code for an embedded system contains
Small portions of assembly code for processor initialization and for run-time critical modules Large portions of C (or other high languages) due to maintenance and readability.
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
45
Comparison Assembly / CFeature Access to Memory Mapped System Resources Access to Non-Memory Mapped System Resources Execution Speed Code Size RAM Usage Readability of Code Assembly possible possible maximal minimal minimal low C possible Not possible high low low high Improvements by commenting source code! Comments module registers, main memory or RAM location core registers, debug interface Assembly provides highest potential for optimization of code.
Portability
not possible
possible
Assembly: Rewrite code for new core C: Recompile code for new core
Ease of Reuse
low
high
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
46
Generating Application code
Startup CodeC Compiler
OSEKC Modules
Application CodeC Modules
Libraries
ASM CodeAssembler
ASM Code
ASM Modules
ASM Code
ASM Modules
Object Code
Object Codes
Object Codes
Object Codes
Library Object
Linker
Program Code for Embedded System
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
47
ReferencesTitle DsPIC30F6010 Data Sheet Embedded Microprocessor Systems Real World Design Embedded Systems Design Embedded Systems Architecture Programming Embedded Systems in C and C++ Stuart L. Ball Steve Heath Tammy Neogaard Michael Barr 0-7506-7534-9 Author ISBN Publisher Microchip Elsevier Comments IC datasheet HW and SW aspects of embedded systems
0-7506-5546-1 0-7506-7792-9 1-56592-354-5
Elsevier Elsevier O'Reilly SW Development for ES
25.01.2010
Embedded Systems / Lucian Blaga University / Dr. Houman Amjadi
48