Date post: | 15-Jan-2016 |
Category: |
Documents |
Upload: | rolf-mccarthy |
View: | 216 times |
Download: | 0 times |
1-1Ramesh Yerraballi
EE 319KIntroduction to Microcontrollers
Lecture 1: Introduction, Embedded Sys, Product Life-Cycle, 9S12 Programming
1-2
My Shpeel
“It is important that students bring a certain ragamuffin barefoot irreverence to their studies, they are here not to worship the known but to question it” – Jacob Bronowski
How much do you pay for a Burger?
Per lecture?
Ramesh Yerraballi
1-3Ramesh Yerraballi
Agenda
Course DescriptionBook, Labs, EquipmentGrading CriteriaTAsExpectations/Responsibilities
Embedded SystemsProduct Life Cycle
Analysis, Design, Implementation, Testing Flowcharts, Data-Flow and Call Graphs9S12 Programming
1-4Ramesh Yerraballi
Embedded System
Embedded Systems are everywhere but mostly hidden
MicroProcessor Intel: 4004, ..8080,.. x86 Motorola: 6800, .. 6812,..
PowerPC ARM, DEC,SPARC, Natl
Semi.,… MicroController
Processor+Memory+I/O Ports (Interfaces)
communications
automotive
medical
appliances
consumer electronics
microcomputer
I/O Ports
Microcontroller Electrical,mechanical,
chemical,or
opticaldevices
Embedded system
Bus ADCAnalogsignals
9S12
DAC
Processor
RAM
ROM
I/O Ports
Microcontroller Electrical,mechanical,
chemical,or
opticaldevices
Embedded system
Bus ADCAnalogsignals
9S12
DAC
Processor
RAM
ROM
1-5Ramesh Yerraballi
Microcontroller
MemoryNon-Volatile
oROM oEPROM, EEPROM, Flash
VolatileoRAM (DRAM, SRAM)
InterfacesH/W: PortsS/W: Device DriverParallel, Serial, Analog, Time
1-6Ramesh Yerraballi
Flowchart Example 1.1: Design a flowchart for a system that performs two independent
tasks. The first task is to output a pulse on PTT every 1.024 ms in real time. The second task is to find all the prime numbers, and there are no particular time constraints on when or how fast one finds the prime numbers.
Interrupt triggerClock
Return frominterrupt
void interrupt 7 Clock(void){ PTT = 1; PTT = 0;}
1Connector
main
n = 2
Entry point
Process block
Decision
Function call
1Connector
Prime
Not
Factor(n)
PTT = 1Input/Output
PTT = 0Input/Output
A
B
EF
E
F
<
>
>
Record (n)
n = n+1 DProcess block
C
void main(void){ int n=2; while(1){ if(Factor(n)) Record(n); n = n+1; }}
BCD
A
Function call
1-7Ramesh Yerraballi
Structured Programming
Common Constructs (as Flowcharts)
Block 1
Sequence Conditional While-loop
Block 2Block 1 Block 2 Block
Fork Triggerinterrupt
Join Return from interrupt
1-8Ramesh Yerraballi
Product Life Cycle
Analysis (What?) Requirements ->
Specifications Design (How?)
High-Level: Block Diagrams Engineering: Algorithms,
Data Structures, Interfacing
Implementation(Real) Hardware, Software
Testing (Works?) Validation:Correctness Performance: Efficiency
Maintenance (Improve)
1-9Ramesh Yerraballi
Data Flow Graph
Position Measurement System
1-10Ramesh Yerraballi
Call Flow Graph
Position Measurement System
1-11Ramesh Yerraballi
I/O Ports
Microcontroller Electrical,mechanical,
chemical,or
opticaldevices
Embedded system
Bus ADCAnalogsignals
9S12
DAC
Processor
RAM
ROM
9S12 Assembly Programming
9S12DP5129S12DG128
9S12DP512 Memory Map
Address Size Device Contents
$0000 to $03FF 1024 I/O Ports for Devices Access external devices
$0400 to $07FF 1024 EEPROM: Elec. Erasable Fixed Constants
($2000)$0800 to $3FFF
(8192)
14336
RAM: Random Access Variables and Stack
$4000 to $FFFF 48152 EEPROM: Elec. Erasable Programs and fixed constants
1-12Ramesh Yerraballi
Registers
CC
D
X
Y
SP
PC
8-bit condition code
Two 8-bit accumulators
16-bit index register
16-bit index register
16-bit stack pointer
16-bit program counter
7 0
15X H
Register A Register B
S I N Z V C8
9S12 has 6 registers
1-13Ramesh Yerraballi
9S12 Programming
Simple Program org $3800count rmb 1
org $4000
main ldaa #10 ;loop counter
staa count
loop dec count ; 9,8,… 0
bne loop
stop
org $FFFE
fdb main
Some Basic Instructionsldaa #10 ;make A=10
ldaa $3800 ;A=contents of memory
staa $3800 ;Store contents of A
;into mem
deca ;A=A-1
lsra ;A=A/2 (shift right)
lsla ;A=A*2 (shift left)
adda #10 ;A=A+10
anda #$02 ;A=A&2 (logic and)
eora #$08 ;A=A^8 (exclusive or)
oraa #$03 ;A=A|3 (logic or)
bra loop ;always jump to loop
bne loop ;jump to loop if
; not zero
beq loop ;jump to loop if zero
stop