ES04 MSP430 Architecture
ES04 MSP430 Architecture
Architecture
Microcontroller characteristics
this is one of the first at 16 bit
2
MSP430 main characteristics (1/3)
it to start up
voltages and is
fast
0.8 A for real-time clock mode operation;
very
3
MSP430 main characteristics (2/3)
4
MSP430 main characteristics (3/3)
Flexibility:
Up to 256 kByte Flash; ⇒ keep
the code
used to near ran
memory
Up to 100 pins;
USART, I2C, Timers;
LCD driver;
Embedded emulation; for floating
→
point
Microcontroller performance:
Instruction processing on either bits, bytes or words
Reduced instructions set;
Compiler efficient;
Wide range of peripherals;
Flexible clock system.
5
MSP430 Architecture
16 Bit
Block diagram: 0 00
This Von Neumann all
ojpppp }
is because to
.
bus
.
Address bus is
} flash tniuueeaoifddendateauabuess
position
in those
| RAM
; diff type .
of memory
do
not
overlap
And also some peripheral
are connected and
be configured can
ex .
for a timer
*
at
software level
there is no difference ,
It charge where
only
we willread
Y
MAPPING
MEMORY
Also the peripheral
are
peripheral
mapped as
they are
6
MSP430 architecture
signed
for serial
communication
needa small
Clock
simulation :
debugging
if He red hardware check dock by deck the
stag and also see what happen before and after an operation
we use ,
we can
using
,
,
MSP430X16X Architecture
ALU ADC
DAC I/O Port
Registers
Interrupts
Memory Map:
Start: 0FFE0h volatile
memory
non
End: 0FFDFh
Flash/ROM
Word/Byte ⇒ when finished an
0F800h
for each component have documentation and Start *:
01100h
application we use prom
, and a
firmware to set
, we
write a
9
Interrupt vector table
10
Central Processing Unit (MSP430 CPU) (1/7)
TEST
RAM
• Makes use of only one storage structure for data and
: instructions sets.
Good
,
SAVE
IN FASN
11
Central Processing Unit (MSP430 CPU) (2/7)
is
in
used
the
instruction
any
R1: Stack Pointer (SP): Will point red data the RAM ( the stack )
in area need a
pointer
9
1st: stack can be used by user to store data for later use can
only
move
up or
dow
how much
13
Central Processing Unit (MSP430 CPU) (4/7)
14
Central Processing Unit (MSP430 CPU) (5/7)
Bit Description
8 V Overflow bit. V = 1 Result of an arithmetic operation overflows the signed-variable range.
7 SCG1 System clock generator 0. SCG1 = 1 DCO generator is turned off – if not used for MCLK or SMCLK
6 SCG0 System clock generator 1. SCG0 = 1 FLL+ loop control is turned off
5 OSCOFF Oscillator Off. OSCOFF = 1 turns off LFXT1 when it is not used for MCLK or SMCLK
15
Central Processing Unit (MSP430 CPU) (6/7)
{
generate constants
R3 10 00002h +2, bit processing
R3 11 0FFFFh -1, word processing
16
Central Processing Unit (MSP430 CPU) (7/7)
R4 - R15: General–Purpose
Registers:
These general-purpose registers are
adequate to store data registers,
address pointers, or index values
and can be accessed with byte or
word instructions.
All the bit the
registers are 16 and
first 4 are reserved
17
Central Processing Unit (MSP430X CPU) (1/9)
→
extension of the standard MSPGZO
18
Central Processing Unit (MSP430X CPU) (2/9)
19
Central Processing Unit (MSP430X CPU) (3/9)
20
Central Processing Unit (MSP430X CPU) (4/9)
21
Central Processing Unit (MSP430X CPU) (5/9)
The constants are fixed and are selected by the (As) bits of
the instruction. (As) selects the addressing mode.
Values of constants
generated:
22
Central Processing Unit (MSP430X CPU) (6/9)
23
Addressing Summary
Instruction set
If is a RISC architecture
27 core instructions;
emulated with than 1 instructions
by the compiler → more
'
e. s are
mapped
24 emulated instructions;
z
instruction is orthogonal to the other everyone
The instruction set is orthogonal; every
=
48
Core Instructions
Total Instructions
The MSP430
CPU
Memory Address Register Program Counter Status Register
L
Memory
to change
.w
a
the instruction
fast Destination Operand
-
with a
constant generated
the multiple er
by Source Operand Memory
Multiplexer Mapped I/O
16 16-bit
Registers
PC program
counter
=
single we an
load
,
data only
only
on
instructions
Device Systems and
Operating Modes
System Reset
System reset (1/5)
restart the
of
type the last to microcontroller
Is present in
any
microprocessor ,
and is
way
Nordmare
-
errors
Clock
errors
.
timers
watchdog timer
Hardware
flash
ever
from
memory
System reset (3/5)
Conditions:
Brownout timing:
power supply qggottatsupplyist.MY
befoeadnatethe
oockiimwefietinoffttoeoe g tinetotefasfogions
rn -
Device Systems and
Operating Modes
System Clocks
System clocks (1/16)
MSP430x2xx:
• The Basic Clock Module+ (BCM+);
– One or two oscillators (depending on the device);
– Capable of working with external crystals or
resonators;
– Internal digitally controlled oscillator (DCO);
– Working frequency to up 16 MHz;
– Lower power consumption;
– Lower internal oscillator start-up time.
System clocks (2/16)
MSP430x2xx:
• Basic Clock+:
external with digital
dock is generated oscillator , and be intend or a .
put
by as can ,
k
and
#
components
alternate
( low speed )
o@ Town
.YFk¥U
,
mq→.→aD clock
.
master
a
small
A =
( standard )
signal
create
of the
faster
oscillator
dock
,
we can use the
delay
+0
fleeing
:p
the
more
chip is
.
good is usually
reliable than the oscillator
that
.
MSP430x4xx:
• Frequency Locked Loop (FLL+):
MSP430x4xx:
• FLL+:
datasheet and manual can better how the dock works
Controlling ,
we see
System clocks (5/16)
• 2xx family:
– Does not have full FLL functionality;
– The DCO generates an internal signal (DCOCLK):
» Programmed internally or externally (DCOR bit);
» Controlled by a resistor connected to the ROSC
and VCC pins.
System clocks (9/16)
• 2xx family:
– The DCO control bits:
» RSELx: fDCO range selection;
» DCOx: fDCO defined by the RSEL bits. The step size
is defined by the parameter SDCO;
» MODx: Modulation bits select how often
fDCO(RSEL, DCO+1) is used within the period of 32
DCOCLK cycles.
» The frequency fDCO(RSEL, DCO) is used for the
remaining cycles.
• 2xx family:
– Basic Clock Module+ (BCM+) registers configuration:
» DCOCTL: DCO Control Register
7 6 5 4 3 2 1 0
DCOx MODx
Bit Description
7-5 DCOx Discrete DCO frequency selection step (depends on RSELx bits).
4-0 MODx Modulator selection.
System clocks (11/16)
msp 430 has Standard 1MHz deck
,
if we want to change , we use He first tire of code with some specific bits
• 2xx family:
,
Bit Description
• 2xx family:
– Basic Clock Module+ (BCM+) registers configuration:
» BCSCTL2: Basic Clock System Control Reg. 2
7 6 5 4 3 2 1 0
SELMx DIVMx SELS DIVSx DCOR
Bit Description
7-6 SELMx MCLK source: SELM1 SELM0 = 0 0 DCO
SELM1 SELM0 = 0 1 DCO
SELM1 SELM0 = 1 0 XT2
SELM1 SELM0 = 1 1 LFXT1
5-4 DIVMx MCLK frequency divider: DIVM1 DIVM0 = 0 0 /1
DIVM1 DIVM0 = 0 1 /2
DIVM1 DIVM0 = 1 0 /4
DIVM1 DIVM0 = 1 1 /8
3 SELS SMCLK source: SELS = 0 DCO
SELS = 1 XT2
• 2xx family:
– Basic Clock Module+ (BCM+) registers configuration:
» BCSCTL3: Basic Clock System Control Reg. 3
7 6 5 4 3 2 1 0
XT2Sx LFXT1Sx XCAPx XT2OFF LFXT1OF
Bit Description
7-6 XT2Sx XT2 range select: XT2S1 XT2S0 = 0 0 0.4 – 1 MHz
XT2S1 XT2S0 = 0 1 1– 3 MHz
XT2S1 XT2S0 = 1 0 3– 16 MHz
XT2S1 XT2S0 = 1 1 0.4 – 16-MHz (Digital external)
5-4 LFXT1Sx Low-frequency clock select and LFXT1 range select: XTS=0: XTS=1:
LFXT1S1 LFXT1S0 = 0 0 32768 Hz 0.4 - 1-MHz
LFXT1S1 LFXT1S0 = 0 1 Reserved 1 - 3-MHz
LFXT1S1 LFXT1S0 = 1 0 VLOCLK 3 - 16-MHz
LFXT1S1 LFXT1S0 = 1 1 External 0.4 - 16-MHz
3-2 XCAPx Oscillator capacitor selection: XCAP1 XCAP0 = 0 0 ~1 pF
XCAP1 XCAP0 = 0 1 ~6 pF
XCAP1 XCAP0 = 1 0 ~10 pF
XCAP1 XCAP0 = 1 1 ~12.5 pF
1 XT2OFF XT2 oscillator fault: XT2OFF = 0 No fault condition
XT2OFF = 1 Fault condition
2xx DCO calibration data (in flash info memory segment A).
to
keywords change
y frequency
power consumption
.
supply
voltage range of between 2.2 V and 3.6 V. Higher DCO signal must to be
minmqngisffffestienvbeaseswithfeg
•
Device Systems and
Operating Modes
Watchdog and
Supervisory Voltage System
Watchdog timer (WDT and WDT+) (1/4)
to
Next week we will se what is a
timer it has some dedicated function , ex if there is an infinite
loop stop
if there
,
It is not
is
Something wrong
.
f.
GO red
• Ensure the correct working of the software application;
f⇒fIg÷¥e
W
• Perform a PUC;
reset
de
need to select
• Generate an interrupt request after the counter
some periodic check
reset the counter and make
overflows.
that
Interval timer:
,
,
it work in
be recorded as
simple timer
7 6 5 4 3 2 1 0
on can
Bit Description
7 WDTHOLD WDT hold when WDTHOLD = 1. Useful for energy economy.
6 WDTNMIES Select the NMI interrupt edge when WDTNMI = 1 WDTNMIES = 0 NMI on rising edge
WDTNMIES = 1 NMI on falling edge
1-0 WDTISx Select the WDT timer interval: WDTIS1 WDTIS0 = 0 0 Clock signal / 32768
WDTIS1 WDTIS0 = 0 1 Clock signal / 8192
WDTIS1 WDTIS0 = 1 0 Clock signal / 512
WDTIS1 WDTIS0 = 1 1 Clock signal / 64
Watchdog timer (WDT and WDT+) (4/4)
– Interval mode:
» WDTIFG set after the selected time interval and
requests a WDT interval timer interrupt;
» WDTIE and GIE bits set;
» WDTIFG reset automatically (also can be reset by
software).
Supervisory Voltage System (SVS) (1/2)
Used to monitor:
AVCC supply voltage;
External voltage (located at the SVSIN input).
SVS features:
• Output of SVS comparator accessible by software;
• Low-voltage condition latched (accessible by software);
• 14 selectable threshold levels;
• External channel to monitor external voltage.
Supervisory Voltage System (SVS) (2/2)
Bit Description
7-4 VLDx Voltage level detect. VLD3 VLD2 VLD1 VLD0 = 0000 SVS is off
VLD3 VLD2 VLD1 VLD0 = 0001 1.9 V
VLD3 VLD2 VLD1 VLD0 = 0010 2.1 V
.
.
.
Interrupts
Interrupt management
key
bad input we can use an interrupt to save
power waiting
or
prepare
operations
-
yes
=) execute
returns to the previous state.
a script if called by
We
an
have MASKABLE
extend event
interrupt
and
can
cpu
we
not
can
dot
happen
also
anyway
to the CPU we have or
not
can
• Reset;
,
a routine
for then
of the
.
hardware
They are dated terror
• Interrupts not maskable by GIE; If we do not have a routine the
pagan
will
,
continue
creating failures
• Interrupts maskable by GIE.
,
more
84
Interrupt management
Main Prog
Advantages: ISR
:
Transparent to user :
cleaner code :
:
μC doesn’t waste time polling RETI
Interrupt Flags
Each interrupt has a flag that is raised (set) when the
inat#upt
mask it with
interrupt occurs.
AND
Now to mask
an
is boolean value and
interrupt
an a we can
any
,
,
Giessen
Switch
interrupt enable only
off all
,
Bit that
one
[email protected]
in flag set to O He is will ⇒ source signal never arrive
Bit Description
8 V Overflow bit. V = 1 Result of an arithmetic operation overflows the signed-variable range.
7 SCG1 System clock generator 0. SCG1 = 1 DCO generator is turned off – if not used for MCLK or SMCLK
6 SCG0 System clock generator 1. SCG0 = 1 FLL+ loop control is turned off
5 OSCOFF Oscillator Off. OSCOFF = 1 turns off LFXT1 when it is not used for MCLK or SMCLK
88
Interrupt management
Event-driven programming
The flow of the program is determined by events—i.e.,
sensor outputs or user actions (mouse clicks, key presses)
or messages from other programs or threads.
The application has a main loop with event detection and
event handlers.
Interrupt management
91
Interrupt management
In the
memory
I will have the main code and some
good routines for the
with an
operations
P.C.tothe routine and then
stone
I want
in the
to none
stack counter of the
come back
After
register To The save we
status so now I an ,
: ⇒ If routine is
Other ISRs will not be called. table at the end of bit for each of the table kbytd
,
memory
⇒ 16 line
Ensure that:
The ISR processing time is less than the interrupt’s request
time interval;
To avoid stack overflow -> application program collapse.
Interrupt management
In those address
←
the address
we
find
for the ROUTINE
99
Processing an Interrupt…
return from a
normal routine or from
an
interrupt is quite the some it
,
only changes
the last line ⇒ restore also the state
Interrupt Service Routines
resettle
source
and
yet
If not
-
when the routine is executed the was
If
,
it
interruption will have
Should be short and fast erupt
an
a routine ,
we
the
very
and
out
run
of memory
Require a balance between doing very little – thereby t
leaving the background code with lots of processing – If wait the I
routine
of end
and doing a lot and leaving the background code with begin Herat
a
to ,
and
nothing to do
I have seq .
routine
stack
Applications that use interrupts should: MSP 430 → dear the status register ,
….
your code
….
Device Systems and
Operating Modes
Operation:
• An interrupt event can wake up the CPU from any LPM;
• Service the interrupt request;
• Restore back to the LPM.
Low power operating modes (3/11)
LPM0 to LPM3:
• Periodic processing based on a timer interrupt;
• LPM0: Both DCO source signal and DCO’s DC gen.;
• LPM0 and LPM1: Main difference between them is the
condition of enable/disable the DCO’s DC generator;
• LPM2: DCO’s DC generator is active and DCO is
disabled;
• LPM3: Only the ACLK is active (< 2 μA).
LPM4:
• Externally generated interrupts;
• No clocks are active and available for peripherals.
• Reduced current consumption (0.1 μA).
Low power operating modes (6/11)
• Disabled peripherals:
– Operating with any disabled clock;
– Individual control register settings.
Enter ISR:
• The operating mode is saved on the stack during ISR;
• The PC and SR are stored on the stack;
• Interrupt vector is moved to the PC;
• The CPUOFF, SCG1, and OSCOFF bits are automatically
reset, enabling normal CPU operation;
• IFG flag cleared on single source flags.
Performance on-demand;
120
DMA capability (2/3)
121
DMA capability (3/3)
122
DMA configuration and operation (1/6)
Block diagram:
123
DMA configuration and operation (2/6)
124
DMA configuration and operation (3/6)
125
DMA configuration and operation (4/6)
126
DMA configuration and operation (5/6)
127
DMA configuration and operation (6/6)
128