Upload
others
View
15
Download
0
Embed Size (px)
Citation preview
Embedded Programming
Alexander Nelson
September 16, 2019
University of Arkansas - Department of Computer Science and Computer Engineering
Programming for Embedded
Differences from desktop programming:
• Input/Output
• Math
• Memory and Hardware
• Code Development
Let’s use the Arduino Uno platform as an example
1
Input/Output
Typical Input/Output on Embedded Devices handled by memory
mapped input/output called “ports”
• Memory Mapped Digital I/O
• Serial Ports
• Analog to Digital Converter (ADC or A/D)
2
Arduino Uno (AtMega328P)
ADC Pins
Digital I/O & PWM
Serial UART
Serial I2C
Serial SPI
Power Pins3
AtMega328P Block Diagram
4
AtMega328P Pinout
5
Em
bedd
ed C
ontr
olle
rs87
6
Core CPU Architecture
• Data & Program Memory
Separated
• Registers are 8-bits
• R26-R31 compose three
16-bit values with
upper/lower bits
7
Arithmetic
8
Arithmetic
No floating point support!
Every arithmetic operation completes in at most 2 cycles
9
AtMega328P Pipeline
AtMega328P has 2-stage pipeline
Fetch, execute
Decoding of instruction occurs during fetch cycle
10
Memory
AtMega328P has separate program(flash) memory and data
(SRAM) memory
11
Persistent Storage
Program Memory is persistent (flash)
Data memory is not (SRAM)
AtMega328P has 1K bytes EEPROM (Electrically Erasable
Programmable Read-Only Memory) for persistent data storage
12