LEC 1&2- INTRODUCTION TO ESD
LEC 3&4 - MODULAR APPROACH TO ESD
LEC 5&6 - SALIENT FEATURES OF MODERN MICROCONTROLLER
LEC 7&8 - Elements of Microcontroller Ecosystem
LEC 9&10 - POWER SUPPLY FOR ES
LEC 11,12&13- INTRODUCTION TO MSP430 and Mem Archi
LEC 14 – PROGRAMMING METHODS FOR MSP0
LEC 15,16,17,18,19,20 – Physical Interfacing
LEC 21 –GIT, CCS Installa on and Embedded C
LEC 22- MSP430 Digital I/O
I/O ports of MSP430G2553
1. MSP430G2553 (20 pin) has two Ports P1 and P2.
2. MSP430G2553 (28 pin) has three ports P1, P2, P3.
3. Each Port has 8 I/O pins.
4. Any I/O can be made input or output, and can be individually read or wri en to.
5. Individually configurable interrupts on P1 and P2.
6. Choice of individually configuring pull-up or pull-down resistors.
7. The ports are configured by several 8-bit Peripheral Registers.
The structure of a Port.
Fig.: GPIO Port Circuit Diagram
Digital I/O Registers
The MSP430 communicates with the Digital I/O Peripherals through a set of 8-bit Peripheral Registers:
1. PxDIR
2. PxIN
3. PxOUT
4. PxREN
5. PxSEL and PxSEL2
PxDIR Register
'P' stands for port
‘x' stands for port number (Upto 3 ports available on MSP430G2553, based on package selected)
It is an 8-bit register. It is used to define whether a pin is to be used as an input or as an output.
If value of a bit in PxDIR register is '0', it is set as input.
If value of a bit in PxDIR register is '1', it is set as output.
Default value of PxDIR register for all ports is '0'
PxIN
This 8-bit register stores the value of input on a port. Based on the value of logic low and logic high for MSP430 MCU, the
voltage value read on the input pin will be classified as logic low or logic high.
The 'O' value of a bit in PXIN register indicates the input value of bit as low.
The '1' value of a bit in PXIN register indicates the input value of bit as high.
For reading the value of a GPIO, set the pin as input using PxDIR register then read the value of bit in PxIN register
PxOUT
This 8-bit register sets the digital value on a port.
Se ng the value of a bit as ‘0’ in PxOUT register sets the output value of the bit as low.
Se ng the value of a bit as ‘1’ in PxOUT register sets the output value of the bit as high.
For se ng the value of a GPIO, set the pin as output using PxDIR register then set the value of bit in PxOUT register.
PxREN
The 8-bit register enales the pullup or pulldown esstoe for a given pin.
Se ng the value of a bit as ‘0’ in PxREN register disables the pull-up/pull-down resistor.
Se ng the value of a bit as ‘1’ PxREN register enables the pull-up/pull-down resistor.
Once PxREN is set, PxOUT value is set to select between pul-lup or pull-down on pin.
If PxOUT is set as ‘0’, then pin is pulled down.
If PxOUT is set as ‘1’, then pin is pulled up.
PxSEL and OP
Mul ple func ons are available on a single pin, PxSEL and PxSEL2 register are used to select func on of a given pin.
Bit Manipula on
In order to be able to configure the I/O and program the MSP430 we need to first understand some techniques to
read/assess/configure/test/manipulate individual bits in a register.
Bitwise Opera on:
1. OR (|)
2. AND (&)
3. XOR (^)
4. Shi Right (>>)
5. Shi Le (<<)
6. NOT (~)
Se ng Outputs
The I/Os are independently configurable!
Example 1: For Port P1, suppose there are 8 LEDs connected on each pin. Suppose we have to turn on the LED on
P1.3, without changing any configura on on the rest of the port.
Based on the logic that x|0=x and x|1=1, there are a number of aways to set a bit:
1. P1OUT = P1OUT | BIT;
2. P1OUT |= BIT3;
3. P1OUT = PAOUT | OxO8;
Reading Inputs
Suppose there is a switch connected to P1.5 and we need to read the value of the pin.
If((PIN & BIT5)==0)
//task1
else
//task2
LEC 23- MSP430 Digital I/O: Switch Interfacing
Possible ways for switch connec on
Pull-Up Configura on
#include <msp430.h>
#define SW BIT4 // Switch -> P1.4 (External Switch, Pull-Up configura on)
#define LED BIT7 // Red LED -> P1.7 (External Switch, Ac ve-High configura on)
void main(void) {
WDTCTL = WDTPW | WDTHOLD; //! Stop Watchdog
P1DIR |= LED; // Set LED pin -> Output
P1DIR &= ~SW; // Set SW pin -> Input
P1REN |= SW; // Enable Resistor for SW pin
P1OUT |= SW; // Select Pull Up for SW pin
while(1)
{
if(!(P1IN & SW)) // If SW is Pressed
{
__delay_cycles(20000); // Wait 20ms to debounce
while(!(P1IN & SW)); // Wait ll SW Released
__delay_cycles(20000); // Wait 20ms to debounce
P1OUT ^= LED; // Toggle LED
}
}
}
Pull-Down Configura on
#include <msp430.h>
#define SW BIT4 // Switch -> P1.4 (External Switch, Pull-Down configura on)
#define LED BIT7 // Red LED -> P1.7 (External Switch, Ac ve-High configura on)
void main(void) {
WDTCTL = WDTPW | WDTHOLD; //! Stop Watchdog
P1DIR |= LED; // Set LED pin -> Output
P1DIR &= ~SW; // Set SW pin -> Input
P1REN |= SW; // Enable Resistor for SW pin
P1OUT &=~ SW; // Select Pull down for SW pin
while(1)
{
if(P1IN & SW) // If SW is Pressed
{
__delay_cycles(20000); // Wait 20ms to debounce
while((P1IN & SW)); // Wait ll SW Released
__delay_cycles(20000); // Wait 20ms to debounce
P1OUT ^= LED; // Toggle LED
}
}
}
LEC 24- Clock System and Reset
Basic Clock Module
MSP430 Resets
Power on Reset (POR): It’s a device reset and is generated by condi ons related to hardware. The condi ons
given are:
i. Powering up the device
ii. Browning out reset
iii. Nega ve edge signal on RST/NMI (User reset)
Power Up Clear (PUC): A PUC is generated by the so ware condi ons; it is always generated whenever POR is
generated. The following condi ons trigger PUC:
i. A POR signals
ii. Watchdog mer expira on
iii. Watchdog mer security key viola on
iv. A Flash memory security key voli on
LEC 25/26- Interrupts in MSP430
An Interrupt refers to the transfer of program control from a currently running program to another service program as a result of
an external or internal generated request.
Interrupts
The code which handles an interrupt is called an Interrupt Handler or Interrupt Service Rou ne (ISR)
Interrupts can be requested by most peripheral modules like Timers, GPIO and some n the core of the MCU,
such as clock generators
Each interrupt has a flag, which is set when condi on of interrupt occurs.
There are 3 types of interrupts
1. System Reset
2. Non Maskable
3. Maskable
4. Vectored
5. Non Vectored
Non Maskable Interrupts
Occurs if, Oscillator Fault
Occurs if, Access viola on to memory.
Occurs if, NMI pin if it has been configured for interrupt rather than reset
RST/NMI Pin
At power-up the RST?NMI pin is configured as r=the reset pin.
Its func on s selected in the Watchdog control register WDTCTL
IF RST/NMI pin is set to the reset func on, the CPU is held in the reset state as long as the RST/NMI pin is held
low. Ater the input changes to high state, the CPU starts program execu on at the word address store in the
reset vector, 0FFFEh
LEC 27-SSD with MSP430, Low power modes in MSP430
LEC 28-LCD Interfacing with MSP430
LEC 29-Timer/Counter in MSP430
LEC 30-PWM Modula on
LEC 31-ADC converter in MSP430
LEC 32-DAC using R2R Ladder
LEC 33-Serial Communica ons protocol and USCI Module in MSP430
LEC 34-Timer in Capture mode
LEC 35-Coding
LEC 36-Building an Electronic Project
LEC 37-Circuit Prototyping Methods
LEC 38,39-Single Purpose Computers