Professional Documents
Culture Documents
EE 319K Introduction To Microcontrollers: Lecture 1: Introduction, Embedded Systems, Product Life-Cycle, ARM Programming
EE 319K Introduction To Microcontrollers: Lecture 1: Introduction, Embedded Systems, Product Life-Cycle, ARM Programming
Introduction to Microcontrollers
Lecture 1: Introduction,
Embedded Systems, Product
Life-Cycle, ARM Programming
1-2
Useful Info
• No labs this week!
• Lab lectures start this Friday
• F 4–5, M 6:30–7:30 and 7:30-8:30 (ECJ 1.202)
• 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 HW
• 2/23 7–8:30 (15%) 4/6 7–8:30 (20%) Final TBD (25%)
• Most of the learning is in the labs
• 10 labs 30% of grade
• HW is important too so 10% for motivation
• Read the book and lab manual!
• Canvas, Piazza, and
users.ece.utexas.edu/~valvano/Volume1/
1-3
Action Items
1-4
DOs and DON’Ts
DO DON’T
•Read •Don’t cheat!
• Book, lab, datasheets •Never look at another
•Try before seeking help student’s code (current
•Follow Piazza/Canvas or previous)
•Discuss material with •Don’t let your partner do
others all the work
•Homework (not labs) in •Don’t copy software from
groups book or web without
•Consult the web attribution
•Track due dates •Don’t expect handholding
1-5
EE306 Recap: Digital Logic
+3.3V
p-type source A ~A
A p-type n-type ~A
gate drain 74HC04
0 V active off +3.3V
+3.3V off active 0V A n-type
~A A ~A
drain
0 1
gate source
1 0
1-6
EE306, Also
• Problem solving
• Programming
• Debugging
1-7
EE302 Recap: Ohm’s Law
V=I*R Voltage = Current * Resistance
I=V/R Current = Voltage / Resistance
R=V/I Resistance = Voltage / Current
I = 3.7mA
I
Battery
V R V=3.7V R = 1k
Resistor
1-9
Microcontroller
Processor – Instruction Set + memory + accelerators
Ecosystem
Memory
Non-Volatile
o ROM
o EPROM, EEPROM, Flash
Volatile
o 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
Texas Instruments TM4C123
Cortex M4 Systick
System Bus Interface NVIC
1-11
LaunchPad Switches and LEDs
R1 0
TM4C123 PF0
PF4
Serial PA1 R13 0 5V
PA0 Green
R29 Blue Red
+5 PB1
0
PD5 330 330 330
USB R12 SW1 SW2
R25 PD4 PF3
PB0 0
0
PD0 R11
R9 0
PB6 PF2
0
R10 0
PD1 R2 DTC114EET1G
PB7 PF1
0
1-13
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.5420 - - - SEL SEL SEL SEL SEL GPIO_PORTF_AFSEL_R
4002.551C - - - DEN DEN DEN DEN DEN GPIO_PORTF_DEN_R
1-15
Data Flow Graph
LCD main
LCD
display driver Fixed-point
0 to 2.000
1-16
Call Flow Graph
SysTick
main ISR
1-17
Structured Programming
Common Constructs (as Flowcharts)
Sequence Conditional While-loop
Block 1
1-18
Flowchart
Toaster oven:
main Cook
Output heat
Input from is on
switch Too cold
return
1-19
Flowchart
Example 1.3. Design a flowchart for a system that performs two independent
tasks. The first task is to output a 20 kHz square wave on PORTA in real time
(period is 50 ms). The second task is to read a value from PORTB, divide the value
by 4, add 12, and output the result on PORTD. This second task is repeated over
and over.
main A
void SysTick_Handler(void){
Input n from B Clock PORTA = PORTA^0x01; E
< } >
PORTB
PORTA = E void main(void){ A
PORTA^1 unsigned long n;
n = (n/4)+12 C while(1){
> n = PORTB; B
n = (n/4)+12; C
PORTD = n; D
Output n to }
PORTD D
}
1-20
ARM Cortex M4-based System
Microcontroller System bus
ARM® CortexTM-M
processor
Input
PPB ports
Internal
Advanced
peripherals High-perf Output
Bus ports
Instructions
Flash ROM Data
ICode bus DCode bus RAM
1-21
ARM Cortex M4-based System
RISC machine
Pipelining effectively provides single cycle operation for many instructions
Thumb-2 configuration employs both 16 and 32 bit instructions
CISC RISC
Many instructions Few instructions
Instructions have varying lengths Instructions have fixed lengths
Instructions execute in varying times Instructions execute in 1 or 2 bus cycles
Many instructions can access memory Few instructions can access memory
Load from memory to a register
Store from register to memory
In one instruction, the processor can both No one instruction can both read and write
read memory and memory in the same instruction
write memory
Fewer and more specialized registers. Many identical general purpose registers
some registers contain data,
others contain addresses
Many different types of addressing modes Limited number of addressing modes
register,
immediate, and
indexed.
1-22
ARM ISA: Thumb2 Instruction Set
Variable-length instructions
ARM instructions are a fixed
length of 32 bits
Thumb instructions are a fixed
length of 16 bits
Thumb-2 instructions can be
either 16-bit or 32-bit
Thumb-2 gives approximately 26%
improvement in code density over
ARM
Thumb-2 gives approximately 25%
improvement in performance over
Thumb
1-23
ARM ISA: Registers, Memory-map
R0 0x0000.0000
R1 256k Flash
R2 ROM 0x0003.FFFF
R3
R4 0x2000.0000
General R5 32k RAM
purpose R6 0x2000.7FFF
registers R7
R8
R9 0x4000.0000
R10
I/O ports
R11 0x400F.FFFF
R12
Stack pointer R13 (MSP) 0xE000.0000
Link register R14 (LR) Internal I/O
Program counter R15 (PC) PPB 0xE004.1FFF
1-25
LC3 to ARM – Arithmetic/Logic
1-26
LC3 to ARM – Control
BR Target ; PC <- Address of Target
B Target
BRnzp Target ; PC <- Address of Target
B Target
BRn Target ; PC <- Address of Target if N=1
BMI Target ; Branch on Minus
BRz Target ; PC <- Address of Target if Z=1
BEQ Target
BRp Target ; PC <- Address of Target if P=1
No Equivalent
BRnp Target ; PC <- Address of Target if Z=0
BNE Target
BRzp Target ; PC <- Address of Target if N=0
BPL Target ; Branch on positive or zero (Plus)
BRnz Target ; PC <- Address of Target if P=0
No Equivalent
1-27
LC3 to ARM – Subs,TRAP,Interrupt
1-28
ARM is a Load-Store machine
1-29
SW Development Environment
Editor KeilTM uVision®
Simulated Processor
Source code Start Microcontroller
Start
; direction register Debug
LDR R1,=GPIO_PORTD_DIR_R Session Memory
LDR R0,[R1]
ORR R0,R0,#0x0F
; make PD3-0 output I/O
STR R0, [R1]
1-30