Download presentation
Presentation is loading. Please wait.
Published byMauro Prada Azeredo Modified over 6 years ago
1
Embedded Systems Computer-based systems which do not appear to be computers Complexity is hidden from the user Embedded systems are much more common than desktop/laptop systems Interact with users via simple interface: Digital camera, TV, cellphone, … Interact with another device, invisible to user: Disk drive, memory stick, anti-lock braking system, …
2
Tight Constraints Embedded design methodology: Be Efficient!
Majority of embedded products are in cost critical markets (i.e. consumer electronics) Other applications are in performance/power critical markets (i.e. military, medical) Constraints include: Maufacturing cost, Design cost, Performance, Power, Time-to-Market Very different from traditional software engineering Moore’s law will save you eventually Embedded system designers should be control freaks Need to have explicit control over timing, memory Why trust a compiler/interpreter/OS?
3
Application Specificity
Embedded systems are generally application-specific Perform one task or set of related tasks Some devices blur the line (i.e. cell phones) Allows design to be focused on one application Unlike general-purpose systems (i.e. laptop) Higher design efficiency is possible Special-purpose vs. general purpose (i.e. video games)
4
Hardware/Software Codesign
Hardware and software are often designed together General-purpose systems use HW and SW developed by different companies Greatly improved optimization is possible Include only HW/SW needed for your application More work for the designers Must understand both HW and SW
5
Generic ES Structure microcontroller sensors ADC DAC actuators IP FPGA
Sensors receive data from the world Actuators cause events in the world Application-Specific Integrated Circuit (ASIC)- special-purpose hardware Field Programmable Gate Array (FPGA) - reconfigurable hardware
6
Sensors Receive data from the environment
Motion - IR/ultrasonic detectors, potentiometers, encoders Light - Photoresistors, cameras Touch - Capacitive touch, pressure sensors Variety of physical principles used Many sensors are analog
7
Actuators Cause external events
Mechanical - motors Audio – speakers, buzzers Visual – LED, LCD, laser May consider external communication to be actuation Many actuators are analog
8
Analog/Digital Conversion
Analog-to-Digital Converter (ADC) Converts analog data to digital data Used to interface with analog sensors Digital-to-Analog Converters (DAC) Converts digital signals to analog signals Used to interface with analog actuators
9
Intellectual Property (IP) Core
An integrated circuit which performs one function Cheap in high volume Very useful for common tasks Network controllers (ethernet, CAN) Audio/Video (audio codec, VGA controller) Must interact with the microcontroller Consider communication protocol
10
Field Programmable Gate Array (FPGA)
Hardware which can be reconfigured via RAM Logic Block Interconnect Faster than SW, slower than ASIC No fabrication needed
11
Microcontrollers Microcontrollers are the center of the system
Accept input data, process it, make decisions, cause output events Hardware/Software Interface Write code, execute it on a microcontroller Microcontroller interacts with hardware components
12
General-Purpose vs. DSP
Used in for any application Many features included Digital Signal Processors (DSP) Made to support DSP functions Vector instructions Cheaper but more limited
13
Software Translation Machine language: CPU instructions represented in binary Assembly language: CPU instructions with mnemonics Easier to read Equivalent to machine language High-level language: Commonly used languages (C, C++, Java, etc.) Much easier to use All software must be translated into the machine language of the microcontroller
14
Compilation/Interpretation
Compilation: Translate instructions once before running the code C, C++, Java (partially) Translation occurs only once, saves time Interpretation: Translate instructions while code is executed Basic, Java (partially) Translation occurs every execution Translation can adapt to runtime situation
15
Why C for Embedded Systems?
Easier to use than Assembly language Allows more control than higher-level languages (Java, Python, etc. C example Python example int a, b, c; a = b + c a = b + c; How much memory is used in each example?
16
Compilation Example a = b + c; 10010001000000110000001000000001
Compiler lw $r1, ($s1) lw $r2, ($s2) add $r3, $r2, $r1 sw $r3, ($s3) Load b from memory Load c from memory Add b and c Store result a in memory Assembler add $r3 $r2 $r1
17
Getting Started Prints “hello, world” to the screen
#include <stdio.h> main() { printf(“hello, world\n”); } Prints “hello, world” to the screen Type this in with a text editor and save it as hello.c
18
Running a Program You will need a text editor and a compiler
Debugger will be needed later I use GNU tools emacs text editor gcc C compiler gdb C debugger Can use these on Windows but MacOS and linux are easier
19
Eclipse IDE On Windows you might use the Eclipse Integrated Development Environment (IDE) Puts all tools together in a nice graphic user interface Need Java Runtime Environment (JRE) to run it Can also use Microsoft Visual Studio (costs money)
20
Compiling and Running Emacs window Compile and run
21
Breaking Down Hello.c #include <stdio.h> main()
Tells the compiler to use the library functions described in stdio.h printf (the print function) is inside stdio main() Beginning of the main function All code execution starts at main
22
Breaking Down Hello.c { } printf( … );
Curly brackets are used to group lines of code All functions start and end with curly brackets printf( … ); This function prints to the screen The argument is in parenthesis The argument is what is printed Notice the semicolon at the end of the line
23
Breaking Down Hello.c “hello, world\n”
This is the argument to printf which appears on the screen It is a string because it is in quotes (“”) \n is a special character with indicates newline main() { printf(“hello, ”); printf(“world”); printf(“\n”); }
24
Variables Variables are strings which represent values in the program
Similar to algebraic variables All variables have a type which must be declared int x; float y; Type determines how arithmetic is performed, how much memory space is required
25
Celsius Conversion A program to convert Fahrenheit to Celsius, print a table 20 -6 4 … Will need variables to hold numbers for computation Need to perform arithmetic C = (5/9)(F-32)
26
Fahrenheit – Celsius Program
main(){ int fahr, celsius; int lower, upper, step; lower = 0; /* lower limit */ upper = 300; /* upper limit */ step = 20; /* step size */ fahr and celsius hold temperatures lower and upper limit the fahrenheit values step is the size of the increment
27
Fahrenheit – Celsius Program
fahr = lower; while (fahr <= upper) { celsius = 5 * (fahr-32) / 9; printf("%d\t%d\n", fahr, celsius); fahr = fahr + step; } While loop iterates fahr from 0 to 300 fahr updates each iteration Assignment to celsius does the work
28
For statement fahr=0 is initialization
main(){ int fahr; for (fahr=0; fahr<=300; fahr += 20) printf(“%3d %6.1f\n”, fahr, (5.0/9.0)*(fahr-32)); } fahr=0 is initialization fahr<=300 is the terminating condition fahr+=20 is the increment step
29
Symbolic Constants #define is a compiler directive
#define LOWER 0 main(){ int fahr; for (fahr=LOWER; fahr<=300; fahr += 20) printf(“%3d %6.1f\n”, fahr, (5.0/9.0)*(fahr-32)); } #define is a compiler directive name is replaced by text
30
Character Input/Output
c = getchar() Gets a single character from the input stream Typically the keyboard (stdin) Waits for the data input putchar(c) Sends a character to the output stream Typically the screen (stdout)
31
Stream Copying c is an int to hold the EOF character
int c; c = getchar(); while (c != EOF) { putchar(c); } Copies characters from input to output EOF is a unique end-of-file character Defined in stdio.h (ctrl-d) c is an int to hold the EOF character
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.