Professional Documents
Culture Documents
C Sec Eiot Unit 2
C Sec Eiot Unit 2
C Sec Eiot Unit 2
Syllabus:
MSP430 Family, Features, Architecture, Register Set, Memory Space, Addressing Modes,
Features:
Major Versions
MSP430 MSP430X
If Flash is More the 64 KB
MSP430Fxxxx series [ F – Flash] > MSP430Cxxxx Series[ C for Code ROM]
MSP430
Note: Some more versions with inbuilt LCD drivers, increased ADC pins are also
available.
Architecture of Basic MSP430 Processor
Pin Diagram of MSP430G2 series
Memory Space
Register Organization
R0/PC – Program Counter R1/ SP -- Stack Pointer
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved V SCG1 SCG0 OSC OFF CPU OFF GIE N Z GC
R2 and R3 - Constant Generator – Helps in addressing time for few instruction operations
like INC/DEC etc.
Timers
1. Timer A
2. Timer B [ for high end versions]
TIMER A: It typically has three channels and is much more versatile than the simpler timers .
Timer A can handle external inputs and outputs directly to measure frequency, time-stamp
inputs, and drive outputs at precisely specified times, either once or periodically. There
are internal connections to other modules so that it can measure the duration of a signal
Protect the system against failure of the software, such as the program becoming
trapped in an un-intended, infinite loop.
The watchdog counts up and resets the MSP430 when it reaches its limit.
The watchdog is always active after the MSP430 has been reset.
Auxiliary Peripherals
❑ ACLK Slow
Clock [RTC, Timers, LCD, Serial]
•Main Clock (MCLK) : CPU source that may be driven by the internal Digitally Controlled
Oscillator (DCO) up to 25 MHz or with external crystal.
•Sub-Main Clock (SMCLK) : Source for faster individual peripheral modules that may be
driven by the internal DCO up to 25 MHz or with external crystal
•Auxiliary Clock (ACLK) : Source for individual peripheral modules driven by the internal
low-power oscillator or external crystal
LOW POWER MODES
Low Power Modes (LPMs) represents the ability to scale the microcontroller’s power usage by
shutting off parts of the MSP430.
The CPU and several other modules such as clocks are not always needed. Many applications
which wait until a sensor detects a certain event.
It can benefit from turning off unused (but still running) parts of the microcontroller to
save energy, turning them back on quickly when needed.
•LPM0 :CPU and MCLK are disabled while SMCLK and ACLK remain active.
•LPM1 : CPU and MCLK are disabled, and DCO and DC generator are disabled
if the DCO is not used for SMCLK. ACLK is active.
•LPM2 : CPU, MCLK, SMCLK, DCO are is enabled DC generator remains enabled.
ACLK is active
•LPM3 :CPU, MCLK, SMCLK, DCO are disabled, DC generator is disabled,
ACLK is active
• LPM4:CPU is disabled, ACLK is disabled, MCLK and SMCLK are disabled
DCO’s dc-generator is disabled Crystal oscillator is stopped
Programming Model
Instruction Format
OR
Transfer Instructions
Arithmetic Instructions
Logical Instructions
7 6 5 4 3 2 1 0
P1IN
P1OUT
P1DIR 1
7 6 5 4 3 2 1 0
P1IN x
P1OUT 1
P1DIR 1
}
for (i = 50000; i != 0; i--)
{
P1OUT ˆ= 0x01; // Toggle P1.0 using exclusive-OR
// with Delay
// ^ SYMBOL IS ALTER THE BIT
}
}
Try some more examples:
Use the Port Programming for the pins as P1.0 - LED1 P1.6 - LED2
(i) ON and OFF the LEDs simultaneously (II) Glow the LEDs alternatively
#INCLUDE <MSP430.H>
VOID MAIN()
{
P1OUT = 0x00 ;
_DELAY_CYCLES(1000) ;
}
}
#INCLUDE <MSP430.H>
VOID MAIN()
{
P1OUT = 0x00 ;
_DELAY_CYCLES(1000) ;
}
}
#INCLUDE <MSP430.H>
VOID MAIN()
{
WDTCTL = WDTPWD + WDTHOLD; // CLEAR OR STOP WATCH DOG TIMER
P1DIR = 0x 41 ; // 0 1 00 000 1 = 41 H // MAKE P1.0 AND P1.6 AS OUTPUT PINS
}
}
GLOW THE TWO LEDs THIS TIME
ALTERNATIVELY
#INCLUDE <MSP430.H>
VOID MAIN()
{
_DELAY_CYCLES(1000) ;
}
}
GLOWING PATTERN OF LEDs 1. ALL ON, 2. ALTERNATIVELY ON, 3. 4 ON 4 OFF, 4. AAL ARE
OFF
#INCLUDE <MSP430.H>
VOID MAIN ()
{
WDTCTL = WDTPWD + WDTHOLD; // CLEAR OR STOP WATCH DOG TIMER
P1DIR = 0x FF ; // MAKE ALL PINS OF PORT 1 AS OUTPUT
WHILE (1)
{
P1OUT = 0x FF ; // ALL LEDs ARE ON
_DELAY_CYCLES(1000) ; GENERATE A DELAY OF 1 SEC = 1000 milliseconds
}
ELSE
{
P1OUT = 0x 00 ; // ALL LEDs ARE OFF
_DELAY_CYCLES(1000) ; GENERATE A DELAY OF 1 SEC = 1000 milliseconds
}