msp430 Unit4
msp430 Unit4
msp430 Unit4
A pattern used for selecting bits is called a mask and has all zeroes except for a 1 in the position that
we want to select.
Clearing a bit (to 0) is done using AND operation- x & 0 = 0 and x & 1 = x.
P1OUT &= ˜ BIT3
Features:
➢ 8 S/w selectable time intervals
➢ Two modes: Watchdog & Interval Timer
➢ available as WDT & WDT+
➢ WDTCTL register access is password protected
➢ can be stopped to conserve power
➢ clock fail safe feature
WATCHDOG
Supervision (Watchdog)mode
• Ensure correct working of software program
• Configured with 32ms reset interval using SMCLK
• Writing wrong password or expiration of time interval performs PUC
• Generate interrupt when counter overflows
Interval timer
▪ Provides periodic interrupts
▪ Independent timer generates standard interrupt when counter overflows
periodically
WatchDog
#include <io430x11x1.h> // Specific device
Timer // Pins for LEDs and button
EXAMPLE #define LED1 P2OUT_bit.P2OUT_3
#define LED2 P2OUT_bit.P2OUT_4
#define B1 P2IN_bit.P2IN_1
// Watchdog config: active , ACLK /32768 -> 1s interval; clear counter
#define WDTCONFIG (WDTCNTCL|WDTSSEL)
// Include settings for _RST/NMI pin here as well
void main (void)
{
WDTCTL = WDTPW | WDTCONFIG; // Configure and clear watchdog
P2DIR = BIT3 | BIT4; // Set pins with LEDs to output
P2OUT = BIT3 | BIT4; // LEDs off (active low)
for (;;) { // Loop forever
LED2 = ˜IFG1_bit.WDTIFG; // LED2 shows state of WDTIFG
if (B1 == 1) { // Button up
LED1 = 1; // LED1 off
} else { // Button down
WDTCTL = WDTPW | WDTCONFIG; // Feed/pet/kick/clear watchdog
LED1 = 0; // LED1 on
}
}
}
CLOCK Heart beat of our system
MSP430's rich clock ecosystem provides three internal clocks from a variety of clock sources.
VLO :
Very Low-frequency Oscillator (VLO)
extremely low-power
Ex: reading a sensor
REFO:
REFerance Oscillator (REFO)
common "watch crystal" frequency
Ex:RTC
XT1 and XT2
External clock inputs
Not all devices provide both
Ex:RTC,USB
DCO:
Digitally Controlled Oscillator (DCO)
fast start-up time
Ex:CPU & many high-speed peripherals
MODOSC:
MODuale OSCillator (MODOSC)
Didicated to ADC
LOW POWER MSP430
Main features of the MSP430 families:
• Low power consumption (around 1 mW/MIPS or less)
• Battery operated embedded systems devices.
This goal can only be accomplished using a design utilizing
low power operating modes.
• Clock frequency
• ambient temperature
• supply voltage
• Peripheral selection
• input/output usage
• memory type.
MODE
▪ Active Mode: All Clocks are active
▪ LPM0: CPU, MCLK Disabled
ACLK, SMCLK,FLL loop control are active
▪ LPM1: CPU, MCLK, FLL loop control are Disabled
ACLK, SMCLK are active
▪ LPM2: CPU, MCLK, FLL loop control, DCO clock are Disabled
DCO’s DC generator is enabled and ACLK is active
▪ LPM3: CPU, MCLK, FLL loop control, DCO clock, DCO’s DC generator are Disabled
ACLK is active
▪ LPM4: CPU, MCLK, FLL loop control, DCO clock, DCO’s DC generator, ACLK are Disabled.
Crystal Oscillator is stopped
RAM retention mode and complete data retention
This mode is used for externally generated interrupts
▪ LPM4.5: Internal regulator is disabled, No data retention and wakeup from NMI/RST
▪ BOR, POR, and PUC are a special type of a non-maskable interrupt with restart behavior of
the complete system.
BROWN OUT RESET(BOR): device reset generated by the following events:
❑Reset when there is a significant drop in the power supply output voltage
▪ Powering up the device
▪ A low signal on the 𝑅𝑆𝑇/NMI pin when configured in the reset mode
▪ A wakeup event from LPMx.5 (LPM3.5 or LPM4.5) modes
▪ A S/w BOR event
MSP430 is inherently low-power, but your design has a big impact on power
efficiency
Features:
➢ Clock for LCD module
➢ Suitable for RTC implementation
➢ Basic interval timer
➢ Simple interrupt capability
BTCNT1: Generates frame frequency for LCD Controller
Clock source: ACLK
BTCNT2: Used as programmable frequency divider with interrupt capability to
provide periodic CPU interrupts and RTC
Clock sources: ACLK,SMCLK, ACLK/256
D.Aswani,Assistent Professor,SVEW
▪ Counter and clock input are the fundamental hardware elements in timer
▪ Counter is incremented for every clock pulse applied at its clock input
Ex: A 16-bit timer counts from 0x0000 to 0xFFFF (0 to 64K)
▪ Counter overflows When it reaches its maximum value (returns to 0 and starts counting)
▪ Generates an interrupt upon overflow
TACTL,
Timer_
A
Control
Registe
r
TACCTL
x,
Timer_A
Capture
/
Compar
e
Control
Register
Output (mode 0): In which output is controlled directly by the OUT bit in TACCRn
Toggle (mode 4): Provides a simple way of switching a load on and off for equal times (50% duty cycle)
Used in UP & Up/Down modes
Disadvantage: Toggles once per timer cycle, So frequency is halved and time period is
doubled
Set (mode 1) and Reset (mode 5): Typically used for single changes in the output, usually in the
Continuous mode.
Reset/Set (mode 7) and Set/Reset (mode 3): Typically used for periodic, edge aligned PWM in Up mode
of the counter 1. When TAR=TACCRn 2. When TAR=0
Toggle/Reset (mode 2) and Toggle/Set (mode 6): Typically used for center-aligned PWM in Up/Down
mode
1. TAR=TACCRn 2. TAR=TACCR0 (to fix waveform sign)
Output
Modes
Output mode Up mode Continuous mode Up/Down mode
1: Set
2: Toggle/Reset
3: Set/Reset
4: Toggle
5: Reset
6: Toggle/Set
7: Reset/Set
▪ Successive Approximation ADC: Fast ADC
Two Versions- ADC10 (10 bits of Output) & ADC12 (12 bits of Output)