1 of 21

EE 319K�Introduction to Microcontrollers

Lecture 1: Introduction, Architecture, Embedded Systems, ARM Programming, Introduction to I/O

Erez, Gerstlauer, Cuevas, Holt, Telang, Tiwari, Valvano, Yerraballi

Lab 1 and 2 are simulated, Lab 3 needs LaunchPad

1-1

2 of 21

Agenda

  • Course Description
    • Book, Labs, Equipment
    • Grading Criteria
    • Expectations/Responsibilities
    • Prerequisites
  • Embedded Systems
    • Microcontrollers
    • Input/Output
  • ARM Architecture
    • Programming
    • Integrated Development Environment (IDE)

1-2

3 of 21

Lab kit

2, Green LED 1.7V 2mA 5mm

2, Red LED 1.8V 2mA 5mm

2, Yellow LED 1.9V 2mA 5mm

6, Carbon 1/4W resistor, 5%, 470,

5, Carbon 1/4W resistor, 5%, 1.5k,

3, Carbon 1/4W resistor, 5%, 12k,

4, Carbon 1/4W resistor, 5%, 10k,

1, Carbon 1/4W resistor, 5%, 24k,

1, 150-ohm speaker (needs soldering),

4, B3F tactile push button switch, B3F-1050,

1, Slide Potentiometer, Mouser 652-PTA20432015CPB10

Students buy

1) Wires and solderless breadboard

2) LaunchPad

3) Digital Multimeter

4) ST7735R Color LCD display

1-3

4 of 21

Useful Info

  • No labs this week!
  • Lab lectures start next week
    • See syllabus
  • Office hours: see Canvas for most recent?
  • TAs have office hours too
    • They are not there to do your work for you
  • One course == common exams and quizzes
    • Exam1 (15%), Exam 2 (20%) Final (20%)
    • Old Exams are ok to study
    • Weekly quizzes on Canvas (20%)
  • Most of the learning is in the labs
    • 10 labs (30%)
  • Read the book and lab manual!
  • Canvas, Piazza, and users.ece.utexas.edu/~valvano/Volume1/

1-4

5 of 21

Action Items

  • Introduce yourself, come to OH
  • Take stock of resources
    • Class Website (Volume1)
    • Piazza for labs, exam, quiz, technical issues
    • Email TAs+Faculty for grading issues
    • E-Book: Search “Valvano e-book”
  • Order TM4C123, LCD, voltmeter, protoboard, wires
  • Install Keil 5 software IDR
  • Read Chapter 1 of book

1-5

6 of 21

DOs and DON’Ts

DO

  • Read
    • Book, lab, datasheets
  • Try before seeking � help
  • Follow Piazza/Canvas
  • Discuss material with � others
  • Consult the web
  • Track due dates

DON’T

  • Don’t cheat!
  • Never look at � another student’s � code (current or � previous)
  • Don’t let your partner � do all the work
  • Don’t copy software � from book or web � without attribution
  • Don’t expect � handholding

1-6

7 of 21

Embedded System

  • Embedded Systems are everywhere
    • Ubiquitous, invisible
    • Hidden (computer inside)
    • Dedicated purpose
  • Microprocessor
    • Intel: 4004, ..8080,.. x86
    • Freescale: 6800, .. 9S12,.. PowerPC
    • ARM, DEC, SPARC, MIPS, PowerPC, Natl. Semi.,…
  • Microcontroller
    • Processor+Memory+�I/O Ports (Interfaces)

1-7

8 of 21

1-8

9 of 21

Job growth in IoT & Embedded Systems

Data science and analytics – 1027%

    • Data mining: 230%
    • Machine Learning: 199%
    • Matlab: 78%

IT & Networking – 120%

    • Computer networking: 91%
    • Network security: 46%
    • Linux system administration: 26%

Engineering & Architecture – 68%

    • Circuit design: 231%
    • AutoCAD: 217%
    • 3D design: 29%

Wearables – 68%

    • Electrical engineering: 159%
    • GPS development: 66%
    • 3D design: 29%

  • Connected Home – 41%
    • Raspberry Pi: 17100%*
    • Circuit design: 231%
    • Microcontroller programming: 225%
  • Web, Mobile and Software Development – 40%
    • Node.js: 86%
    • MongoDB: 63%
    • iPhone app development: 40%
  • Big data, data storage and processing/backend programming – 17%
    • Apache Spark: 1667%*
    • Big data: 183%
    • MongoDB: 63%

EE 445L – Bard, McDermott, Valvano

1-9

10 of 21

Microcontroller

  • Processor – Instruction Set + memory + accelerators
    • Ecosystem
  • Memory
    • Non-Volatile
      • ROM
      • EPROM, EEPROM, Flash
    • Volatile
      • RAM (DRAM, SRAM)
  • Interfaces
    • H/W: Ports
    • S/W: Device Driver
    • Parallel, Serial, Analog, Time
  • I/O
    • Memory-mapped vs. I/O-instructions (I/O-mapped)

1-10

11 of 21

ARM Cortex M4-based System

  • ARM Cortex-M4 processor
  • Harvard architecture
    • Different busses for instructions and data

1-11

12 of 21

ARM ISA: Registers, Memory-map

TI TM4C123�Microcontroller

Condition Code Bit s Indicates

N negative Result is negative

Z zero Result is zero

V overflow Signed overflow

C carry Unsigned overflow

1-12

13 of 21

Cortex M

Registers

SP R13 is stack pointer

LR R14 is link register

PC R15 is program counter

Memory

Addresses are 32 bits

8-bit byte addressable

32-bit accesses 4 locations

1-13

14 of 21

Memory Access

Memory

AREA data,align=2

Stuff SPACE 4

Read from memory

LDR R0,=Stuff

LDR R1,[R0]

Write to memory

LDR R0,=Stuff

MOV R1,#5

STR R1,[R0]

1-14

15 of 21

Texas Instruments TM4C123

ARM Cortex-M4

+ 256K EEPROM�+ 32K RAM

+ JTAG

+ Ports

+ SysTick

+ ADC

+ UART

1-15

16 of 21

LaunchPad Switches and LEDs

  • The switches on the LaunchPad
    • Negative logic
    • Require internal pull-up (set bits in PUR)
  • The PF3-1 LEDs are positive logic

1-16

17 of 21

I/O Ports and Control Registers

The input/output direction of a bidirectional port is specified by its direction register.

GPIO_PORTF_DIR_R , specify if corresponding pin is input or output:

    • 0 means input
    • 1 means output

GPIO_PORTF_DATA_R

GPIO_PORTF_DIR_R

1-17

18 of 21

I/O Ports and Control Registers

Address

7

6

5

4

3

2

1

0

Name

400F.E608

-

-

GPIOF

GPIOE

GPIOD

GPIOC

GPIOB

GPIOA

SYSCTL_RCGCGPIO_R

4002.53FC

-

-

-

DATA

DATA

DATA

DATA

DATA

GPIO_PORTF_DATA_R

4002.5400

-

-

-

DIR

DIR

DIR

DIR

DIR

GPIO_PORTF_DIR_R

4002.551C

-

-

-

DEN

DEN

DEN

DEN

DEN

GPIO_PORTF_DEN_R

  • Initialization (executed once at beginning)
    1. Turn on clock in SYSCTL_RCGCGPIO_R
    2. Wait two bus cycles (two NOP instructions)
    3. Write 1 DIR bit for output or 0 for input
    4. Set DEN bits to 1 to enable data pins
  • Input/output from pin

Input: Read from GPIO_PORTF_DATA_R

Output: Write GPIO_PORTF_DATA_R

1-18

19 of 21

SW Development Environment

1-19

20 of 21

Toggle PF3

Start

LDR R0,=SYSCTL_RCGCGPIO_R

LDR R1,[R0]

ORR R1,#0x20 ;turn on clock F

STR R1,[R0]

NOP ;wait for clock to stabilize

NOP

LDR R0,=GPIO_PORTF_DIR_R

MOV R1,#0x08 ;PF3 output,

STR R1,[R0]

LDR R0,=GPIO_PORTF_DEN_R

MOV R1,#0x08 ;PF3 enable pin

STR R1,[R0]

loop

LDR R0,=GPIO_PORTF_DATA_R

LDR R1,[R0]

EOR R1,#0x08 ;toggle PF3 pin

STR R1,[R0]

LDR R2,=1000000

wait

SUBS R2,R2,#1

BNE wait

B loop

Run in InputOutput_4C123asm

1-20

21 of 21

Summary

  • Embedded System
  • Microcontroller
    • Processor
      • Registers
      • Memory access
      • Addressing modes
    • Memory (RAM, ROM)
    • Input/output
      • Initialization
      • Read from inputs, outputs
      • Write to outputs
  • TM4C123 (ports, memory)

1-21