13
Embedded Programming Alexander Nelson September 16, 2019 University of Arkansas - Department of Computer Science and Computer Engineering

Embedded Programming - csce.uark.edu

  • Upload
    others

  • View
    15

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Embedded Programming - csce.uark.edu

Embedded Programming

Alexander Nelson

September 16, 2019

University of Arkansas - Department of Computer Science and Computer Engineering

Page 2: Embedded Programming - csce.uark.edu

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

Page 3: Embedded Programming - csce.uark.edu

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

Page 4: Embedded Programming - csce.uark.edu

Arduino Uno (AtMega328P)

ADC Pins

Digital I/O & PWM

Serial UART

Serial I2C

Serial SPI

Power Pins3

Page 5: Embedded Programming - csce.uark.edu

AtMega328P Block Diagram

4

Page 6: Embedded Programming - csce.uark.edu

AtMega328P Pinout

5

Page 7: Embedded Programming - csce.uark.edu

Em

bedd

ed C

ontr

olle

rs87

6

Page 8: Embedded Programming - csce.uark.edu

Core CPU Architecture

• Data & Program Memory

Separated

• Registers are 8-bits

• R26-R31 compose three

16-bit values with

upper/lower bits

7

Page 9: Embedded Programming - csce.uark.edu

Arithmetic

8

Page 10: Embedded Programming - csce.uark.edu

Arithmetic

No floating point support!

Every arithmetic operation completes in at most 2 cycles

9

Page 11: Embedded Programming - csce.uark.edu

AtMega328P Pipeline

AtMega328P has 2-stage pipeline

Fetch, execute

Decoding of instruction occurs during fetch cycle

10

Page 12: Embedded Programming - csce.uark.edu

Memory

AtMega328P has separate program(flash) memory and data

(SRAM) memory

11

Page 13: Embedded Programming - csce.uark.edu

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