SlideShare a Scribd company logo
memory mapped IO
Data BUS
data memory
CPU
program memory
pc
sp
ALU
LD r1, a
LD r2, b
ADD r1,r2
ST c
r0
r1
r2
r3
a
b
c
Address BUS
b0
b1
y = 0b00000001; // turn on red
y = 0b00000000; // turn off red
y = 0x00; // turn off red
y = 0x01; // turn on red
LAUNCHPAD DEVELOPMENT BOARD
Embedded Emulation
6-pin eZ430
Connector
Part and Socket
Crystal Pads
Power Connector
Reset Button
LEDs and Jumpers
P1.0 & P1.6
P1.3 Button
Chip
Pinouts
USB Emulator
Connection
• 16kB Flash
• 512B RAM
• 2 Timer_A3’s
• 8 Ch. Comp_A+
• 8 Ch. ADC10
• USCI
10
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
3
MSP 430 ARCHITECTURE
 Architecture Overview
 Memory
 CPU
 Peripherals
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
4
MSP430 ARCHITECTURE
Copyright
2009
Texas
Instruments
All
Rights
Reserved
www.msp430.ubi.pt
5
MEMORY
 Memory Data Size
Byte, Word, Long Word
Byte = 8 bits
Word = 16 bits
Long Word = 32 bits
 Memory Address
Address size = 20 bits
Total addresses = 220 = 1 M
Each address holds 8 bits
A byte requires one address
A word requires two address
A long word requires four
addresses
 RAM Memory
Random Access Memory,
Read/Write Memory,
Holds data as long as power is
applied
Used for changing data
 Flash Memory
Read/ Write memory
Holds information even after
the power is turned off
Used to store programs and
fixed data
MEMORY MAP
Interrupt Vector Table
Flash
Information
Memory
RAM
16-bit
Peripherals
8-bit
Peripherals
8-bit Special Function
Registers
0Fh
0h
0FFh
010h
01FFh
0100h
03FFh
0200h
0FFDFh
0C000h
0FFFFh
0FFE0h
MSP430G2553
010FFh
01000h
7
MSP430 CPU
R2
R3
R4
R5
R7
R8
R10
R9
R11
R12
R13
R6
R14
R15
R0 / PC (Program Counter)
R1 / SP (Stack Pointer)
R2 / CG1
R3 / CG2
R4
R5
R7
R8
R10
R9
R11
R12
R13
R6
R14
R15
20-bit
Address
16-bit
Data
Memory Map …
6
 16 Registers R0 – R15
 Each register holds 16
bits of information
 Special Registers:
PC, SP
 Registers are used for
temporary data
 PC provides program
memory addresses
 SP provides stack
memory addresses
MSP430 PERIPHERALS
 General Purpose I/O Ports
 Timers: 16-bit
 Watchdog Timer
 Serial Communication: I2C, SPI
 Analog to Digital Converter:
 8 Channel/10-bit 200 ksps SAR
 Comparator
 Reset
LAUNCHPAD OUTPUT PORTS
 Port P1 with configurable pins
 Green LED: P1OUT bit 6 (or pin 6)
 Red LED: P1OUT bit 0 (or pin 0)
 P1DIR = Register whose bits configure the
corresponding port pins for input and output.
 P1OUT = Register whose bits turn the
corresponding pins of port P1 on or off
memory mapped IO
Data BUS
data memory
CPU
program memory
pc
sp
ALU
LD r1, a
LD r2, b
ADD r1,r2
ST c
r0
r1
r2
r3
a
b
c
Address BUS
b0
b1
b6
y = 0x01; // turn on red
y = 0x41; // turn on both
y = 0x00; // turn off both
y = y | 0x01 // red on only
y = y & 0xFE // red off only
b0
b1
b6
y = 0b01000000; // turn on green, turn off red
y = 0b01000001; // turn on both
y = 0b00000000; // turn off both
y = y | 0b00000001 // red on, green no change
y = y & 0b11111110 // red off, green no change
y = y | 0b01000000; // green on, everything else no change
y = y | 0x40; // green on only
y = y & 0b10111111; // green off only, everything else no change
y = y & 0xBF; // green off only
CONTROLLING LAUNCHPAD PORTS
BIT6 = 01000000b;
BIT0 = 00000001b;
P1DIR = BIT6 + BIT0; // P1.6 and P1.0 outputs
P1OUT |= BIT6; // P1.6 on (Green LED)
P1OUT &= ~BIT6; // P1.6 off
P1OUT |= BIT0; // P1.0 on (Red LED)
P1OUT &= ~BIT0; // P1.0 off
P1OUT |= BIT6 + BIT0; // both on
P1OUT &= ~(BIT6 + BIT0); // both off
P1OUT ^= BIT6 + BIT0; // toggle both
#define BIT6 01000000b;
#define BIT0 00000001b;
#define BIT6 0x40;
#define BIT0 0x01;
PORT 1
LAUNCHPAD INPUT PORT
 Port P1 with configurable pins
 Press button is connected to pin 3 of port P1
 Button pressed = logic 0
Button released = logic 1
 P1DIR = Register whose bit 3 configures the
corresponding port pin for input. Set it to 0 for input.
CONTROLLING LAUNCHPAD INPUT PORT
BIT3 = 00001000b;
BTN = 00001000b;
P1DIR &= ~BIT3; // P1.3 as input
P1DIR = P1DIR & (~BIT3);
while (P1IN & BIT3 == BIT3) // Wait for button
// press at P1.3
BUTTON INTERRUPT
Main Program {
1. set up button
2. turn on button interrupt in P1
3. enable CPU interrupt
4. do other things
}
Interrupt Vectors
Interrupt Service Routine {
1. double check interrupt source
2. perform button press functions
3. reset button interrupt
}
button interrupt vector
STATE MACHINE PROGRAMMING
BUTTON CONTROL LED FLASHING EXAMPLE
Upon start up, both LEDs flashing with the same period
- When button is pressed, flash only the red LED
- When button is pressed again, flash only the green LED
- When button is pressed for a third time, reset (i.e. have both
LEDs flashing again)
- And so on...
Reset
R & G
R
G
STATE MACHINE EXERCISE
Reset
R & G
on
R only
G only
STATE MACHINE BUTTON
ISR DOES EVERYTHING
Main Program {
1. set up button
2. turn on button interrupt in P1
3. initialize to RG state
4. enable CPU interrupt
5. do other things
}
Interrupt Vectors
Interrupt Service Routine {
1. double check interrupt source
2. perform button press functions
3. update state and flash lights
accordingly
4. reset button interrupt
}
button interrupt vector
state
state declared as global so it
can be accessed by ISR
STATE MACHINE BUTTON
ISR DOES MINIMUM
Main Program {
1. set up button
2. turn on button interrupt in P1
3. initialize to RG state
4. enable CPU interrupt
5. loop forever
flashing lights based on state
}
Interrupt Vectors Interrupt Service Routine {
1. double check interrupt source
2. perform button press functions
3. update state
4. reset button interrupt
}
button interrupt vector
state
state declared as global so it
can be accessed by ISR
LED flashing has spin idle delay so it takes a while to finish, we
want ISR to be rapid so CPU can handle other interrupts if
necessary
TIMER INTERRUPT
Main Program {
1. set up timer
2. turn on timer interrupt
3. enable CPU interrupt
4. do other things
}
Interrupt Vectors
Interrupt Service Routine {
1. double check interrupt source
2. perform timeout events
3. reset timer interrupt (no need
in continuous mode)
}
timer interrupt vector
TIMER AND BUTTON INTERRUPTS
Main Program {
1. set up button
2. turn on button interrupt in P1
3. set up timer
4. turn on timer interrupt
5. enable CPU interrupt
6. do other things
}
Interrupt Vectors
Interrupt Service Routine {
1. double check interrupt source
2. perform button press functions
3. reset button interrupt
}
button interrupt vector
timer interrupt vector
Interrupt Service Routine {
1. double check interrupt source
2. perform timeout events
3. reset timer interrupt (no need
in continuous mode)
}
TIMER AND BUTTON INTERRUPTS
RECORD KEY PRESS TIME EXAMPLE
Main Program {
1. set up button
2. turn on button interrupt
3. set up timer
4. turn on timer interrupt
5. enable CPU interrupt
6. do other things
}
Interrupt Vectors
Button ISR {
1. double check interrupt source
2. record wall clock for each key
3. reset button interrupt
}
button interrupt vector
timer interrupt vector
Timer ISR {
1. double check interrupt source
2. perform timeout events
3. reset timer interrupt (no need
in continuous mode)
}
currentTime
wall clock, updated
by timer ISR
keyPressTime [0]
used by button ISR
keyPressTime [1]
keyPressTime [2]
keyPressTime [3]

More Related Content

Similar to LaunchPad MSP 430

Pic full note
Pic full notePic full note
Microprocessor 8051
Microprocessor 8051Microprocessor 8051
Microprocessor 8051Anil Maurya
 
Basic computer organisation design
Basic computer organisation designBasic computer organisation design
Basic computer organisation design
Sanjeev Patel
 
input
inputinput
Lecture7
Lecture7Lecture7
Lecture7
Mahmut Yildiz
 
Registers
RegistersRegisters
Registers
Jamia Hamdard
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051Rashmi
 
Chp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copyChp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copymkazree
 
8051 Microcontroller Overview by Venkatrao Ramisetti
8051 Microcontroller Overview by Venkatrao Ramisetti 8051 Microcontroller Overview by Venkatrao Ramisetti
8051 Microcontroller Overview by Venkatrao Ramisetti
VenkatraoRamisetti
 
Microcontroller
MicrocontrollerMicrocontroller
MicrocontrollerSpitiq
 
MicrocontrollersII.ppt
MicrocontrollersII.pptMicrocontrollersII.ppt
MicrocontrollersII.ppt
SatheeshMECE
 
introduction to Microcontrollers 8051.ppt
introduction to Microcontrollers 8051.pptintroduction to Microcontrollers 8051.ppt
introduction to Microcontrollers 8051.ppt
jaychoudhary37
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
Thirunavakkarasu kannusamy
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
Sadiq Rahim
 
Memory Reference instruction
Memory Reference instructionMemory Reference instruction
Memory Reference instruction
mahesh kumar prajapat
 
Remote ashok
Remote ashokRemote ashok
Remote ashok
Ashokkumar sekar
 
Tlk43 Controller
Tlk43 ControllerTlk43 Controller
Tlk43 Controller
Joseph
 
Computer instruction
Computer instructionComputer instruction
Computer instruction
Sanjeev Patel
 
8051 training an interactive tutorial
8051 training an interactive tutorial8051 training an interactive tutorial
8051 training an interactive tutorial
Futura infotech
 
8051 architecture
8051 architecture8051 architecture
8051 architecture
sb108ec
 

Similar to LaunchPad MSP 430 (20)

Pic full note
Pic full notePic full note
Pic full note
 
Microprocessor 8051
Microprocessor 8051Microprocessor 8051
Microprocessor 8051
 
Basic computer organisation design
Basic computer organisation designBasic computer organisation design
Basic computer organisation design
 
input
inputinput
input
 
Lecture7
Lecture7Lecture7
Lecture7
 
Registers
RegistersRegisters
Registers
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
Chp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copyChp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copy
 
8051 Microcontroller Overview by Venkatrao Ramisetti
8051 Microcontroller Overview by Venkatrao Ramisetti 8051 Microcontroller Overview by Venkatrao Ramisetti
8051 Microcontroller Overview by Venkatrao Ramisetti
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
 
MicrocontrollersII.ppt
MicrocontrollersII.pptMicrocontrollersII.ppt
MicrocontrollersII.ppt
 
introduction to Microcontrollers 8051.ppt
introduction to Microcontrollers 8051.pptintroduction to Microcontrollers 8051.ppt
introduction to Microcontrollers 8051.ppt
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
Memory Reference instruction
Memory Reference instructionMemory Reference instruction
Memory Reference instruction
 
Remote ashok
Remote ashokRemote ashok
Remote ashok
 
Tlk43 Controller
Tlk43 ControllerTlk43 Controller
Tlk43 Controller
 
Computer instruction
Computer instructionComputer instruction
Computer instruction
 
8051 training an interactive tutorial
8051 training an interactive tutorial8051 training an interactive tutorial
8051 training an interactive tutorial
 
8051 architecture
8051 architecture8051 architecture
8051 architecture
 

LaunchPad MSP 430

  • 1. memory mapped IO Data BUS data memory CPU program memory pc sp ALU LD r1, a LD r2, b ADD r1,r2 ST c r0 r1 r2 r3 a b c Address BUS b0 b1 y = 0b00000001; // turn on red y = 0b00000000; // turn off red y = 0x00; // turn off red y = 0x01; // turn on red
  • 2. LAUNCHPAD DEVELOPMENT BOARD Embedded Emulation 6-pin eZ430 Connector Part and Socket Crystal Pads Power Connector Reset Button LEDs and Jumpers P1.0 & P1.6 P1.3 Button Chip Pinouts USB Emulator Connection • 16kB Flash • 512B RAM • 2 Timer_A3’s • 8 Ch. Comp_A+ • 8 Ch. ADC10 • USCI 10
  • 3. Copyright 2009 Texas Instruments All Rights Reserved www.msp430.ubi.pt 3 MSP 430 ARCHITECTURE  Architecture Overview  Memory  CPU  Peripherals
  • 4. Copyright 2009 Texas Instruments All Rights Reserved www.msp430.ubi.pt 4 MSP430 ARCHITECTURE
  • 5. Copyright 2009 Texas Instruments All Rights Reserved www.msp430.ubi.pt 5 MEMORY  Memory Data Size Byte, Word, Long Word Byte = 8 bits Word = 16 bits Long Word = 32 bits  Memory Address Address size = 20 bits Total addresses = 220 = 1 M Each address holds 8 bits A byte requires one address A word requires two address A long word requires four addresses  RAM Memory Random Access Memory, Read/Write Memory, Holds data as long as power is applied Used for changing data  Flash Memory Read/ Write memory Holds information even after the power is turned off Used to store programs and fixed data
  • 6. MEMORY MAP Interrupt Vector Table Flash Information Memory RAM 16-bit Peripherals 8-bit Peripherals 8-bit Special Function Registers 0Fh 0h 0FFh 010h 01FFh 0100h 03FFh 0200h 0FFDFh 0C000h 0FFFFh 0FFE0h MSP430G2553 010FFh 01000h 7
  • 7. MSP430 CPU R2 R3 R4 R5 R7 R8 R10 R9 R11 R12 R13 R6 R14 R15 R0 / PC (Program Counter) R1 / SP (Stack Pointer) R2 / CG1 R3 / CG2 R4 R5 R7 R8 R10 R9 R11 R12 R13 R6 R14 R15 20-bit Address 16-bit Data Memory Map … 6  16 Registers R0 – R15  Each register holds 16 bits of information  Special Registers: PC, SP  Registers are used for temporary data  PC provides program memory addresses  SP provides stack memory addresses
  • 8. MSP430 PERIPHERALS  General Purpose I/O Ports  Timers: 16-bit  Watchdog Timer  Serial Communication: I2C, SPI  Analog to Digital Converter:  8 Channel/10-bit 200 ksps SAR  Comparator  Reset
  • 9. LAUNCHPAD OUTPUT PORTS  Port P1 with configurable pins  Green LED: P1OUT bit 6 (or pin 6)  Red LED: P1OUT bit 0 (or pin 0)  P1DIR = Register whose bits configure the corresponding port pins for input and output.  P1OUT = Register whose bits turn the corresponding pins of port P1 on or off
  • 10. memory mapped IO Data BUS data memory CPU program memory pc sp ALU LD r1, a LD r2, b ADD r1,r2 ST c r0 r1 r2 r3 a b c Address BUS b0 b1 b6 y = 0x01; // turn on red y = 0x41; // turn on both y = 0x00; // turn off both y = y | 0x01 // red on only y = y & 0xFE // red off only
  • 11. b0 b1 b6 y = 0b01000000; // turn on green, turn off red y = 0b01000001; // turn on both y = 0b00000000; // turn off both y = y | 0b00000001 // red on, green no change y = y & 0b11111110 // red off, green no change y = y | 0b01000000; // green on, everything else no change y = y | 0x40; // green on only y = y & 0b10111111; // green off only, everything else no change y = y & 0xBF; // green off only
  • 12. CONTROLLING LAUNCHPAD PORTS BIT6 = 01000000b; BIT0 = 00000001b; P1DIR = BIT6 + BIT0; // P1.6 and P1.0 outputs P1OUT |= BIT6; // P1.6 on (Green LED) P1OUT &= ~BIT6; // P1.6 off P1OUT |= BIT0; // P1.0 on (Red LED) P1OUT &= ~BIT0; // P1.0 off P1OUT |= BIT6 + BIT0; // both on P1OUT &= ~(BIT6 + BIT0); // both off P1OUT ^= BIT6 + BIT0; // toggle both #define BIT6 01000000b; #define BIT0 00000001b; #define BIT6 0x40; #define BIT0 0x01;
  • 14. LAUNCHPAD INPUT PORT  Port P1 with configurable pins  Press button is connected to pin 3 of port P1  Button pressed = logic 0 Button released = logic 1  P1DIR = Register whose bit 3 configures the corresponding port pin for input. Set it to 0 for input.
  • 15. CONTROLLING LAUNCHPAD INPUT PORT BIT3 = 00001000b; BTN = 00001000b; P1DIR &= ~BIT3; // P1.3 as input P1DIR = P1DIR & (~BIT3); while (P1IN & BIT3 == BIT3) // Wait for button // press at P1.3
  • 16. BUTTON INTERRUPT Main Program { 1. set up button 2. turn on button interrupt in P1 3. enable CPU interrupt 4. do other things } Interrupt Vectors Interrupt Service Routine { 1. double check interrupt source 2. perform button press functions 3. reset button interrupt } button interrupt vector
  • 17. STATE MACHINE PROGRAMMING BUTTON CONTROL LED FLASHING EXAMPLE Upon start up, both LEDs flashing with the same period - When button is pressed, flash only the red LED - When button is pressed again, flash only the green LED - When button is pressed for a third time, reset (i.e. have both LEDs flashing again) - And so on... Reset R & G R G
  • 18. STATE MACHINE EXERCISE Reset R & G on R only G only
  • 19. STATE MACHINE BUTTON ISR DOES EVERYTHING Main Program { 1. set up button 2. turn on button interrupt in P1 3. initialize to RG state 4. enable CPU interrupt 5. do other things } Interrupt Vectors Interrupt Service Routine { 1. double check interrupt source 2. perform button press functions 3. update state and flash lights accordingly 4. reset button interrupt } button interrupt vector state state declared as global so it can be accessed by ISR
  • 20. STATE MACHINE BUTTON ISR DOES MINIMUM Main Program { 1. set up button 2. turn on button interrupt in P1 3. initialize to RG state 4. enable CPU interrupt 5. loop forever flashing lights based on state } Interrupt Vectors Interrupt Service Routine { 1. double check interrupt source 2. perform button press functions 3. update state 4. reset button interrupt } button interrupt vector state state declared as global so it can be accessed by ISR LED flashing has spin idle delay so it takes a while to finish, we want ISR to be rapid so CPU can handle other interrupts if necessary
  • 21. TIMER INTERRUPT Main Program { 1. set up timer 2. turn on timer interrupt 3. enable CPU interrupt 4. do other things } Interrupt Vectors Interrupt Service Routine { 1. double check interrupt source 2. perform timeout events 3. reset timer interrupt (no need in continuous mode) } timer interrupt vector
  • 22. TIMER AND BUTTON INTERRUPTS Main Program { 1. set up button 2. turn on button interrupt in P1 3. set up timer 4. turn on timer interrupt 5. enable CPU interrupt 6. do other things } Interrupt Vectors Interrupt Service Routine { 1. double check interrupt source 2. perform button press functions 3. reset button interrupt } button interrupt vector timer interrupt vector Interrupt Service Routine { 1. double check interrupt source 2. perform timeout events 3. reset timer interrupt (no need in continuous mode) }
  • 23. TIMER AND BUTTON INTERRUPTS RECORD KEY PRESS TIME EXAMPLE Main Program { 1. set up button 2. turn on button interrupt 3. set up timer 4. turn on timer interrupt 5. enable CPU interrupt 6. do other things } Interrupt Vectors Button ISR { 1. double check interrupt source 2. record wall clock for each key 3. reset button interrupt } button interrupt vector timer interrupt vector Timer ISR { 1. double check interrupt source 2. perform timeout events 3. reset timer interrupt (no need in continuous mode) } currentTime wall clock, updated by timer ISR keyPressTime [0] used by button ISR keyPressTime [1] keyPressTime [2] keyPressTime [3]