Microcontrollers: The brain of the bot
               MSP430

                      Cristina Urdiales
           Departamento de Tecnología Electrónica
                   Universidad de Málaga




     International Summer Workshop on microbotics 2011
INTRODUCTION

What is a microcontroller?
                                           MICROPROCESSOR




    0



                                            MICROCONTROLLER




           International Summer Workshop on microbotics 2011
INTRODUCTION

What is a microcontroller?

       TRADITIONAL CIRCUIT             MICROCONTROLLER




          International Summer Workshop on microbotics 2011
INTRODUCTION
Types of microcontrollers
          ✔
            GENERAL PURPUSE, LOW COST
          ✔
            ULTRALOW POWER CONSUMPTION
          ✔
            AVERAGE PERFORMANCE
          Ethernet, VGA, LCD, Touch-screen, etc…
          Standard architectures, Limited OS
          ✔
           HIGH PERFORMANCE
          Linux, windows CE, …
          High graphic performance
          As powerful as a few years old PC
          ✔
           DSPs
          ✔
           MIXED ARCHITECTURE
          DSP+Microprocessors
          ✔
           FPGAs
          Free Hardware




              International Summer Workshop on microbotics 2011
INTRODUCTION

Ultra low power consumption: Examples

  Devices of limited weight
          • Device fed with button battery (80 mAH). Average power
            consumption: 8 uA => 1,14 years

  Devices requiring long term operation:
          • Wireless sensor network: required life 8 years. Average power
            consumption 200 uA. => Battery required 15.000 mAH.




           International Summer Workshop on microbotics 2011
INTRODUCTION

Ultra low power consumption: Examples




         International Summer Workshop on microbotics 2011
MSP430 TI




114




      International Summer Workshop on microbotics 2011
MSP430 TI




International Summer Workshop on microbotics 2011
MSP430 TI
MSP430x1xx Features
      •   Ultra Low Power Consumption
                - Feeding range: 1,8 – 3,6 V
                - Several ULPC modes
      •   Core: CPU RISC 16 bits
                - High processing performance
                - Memory optimization
      •   High performance periferals: ADCs, TIMERs, USARTs,
          comparers, battery level indicators, I2C ...

      •   Flexible clock system

      •   JTAG integrated

      •   Low cost
              - Development system around 50€
              - Microcontrollers 1-3€


          International Summer Workshop on microbotics 2011
MSP430 TI
MSP430x1xx Features
➢
 Von Neumann architecture
➢
 Data and Address buses: 16 bits
➢
 Data format .B and .W




             International Summer Workshop on microbotics 2011
MSP430 TI            REGISTERS

MSP430x1xx Features
       MEMORY MAP




         International Summer Workshop on microbotics 2011
MSP430 TI
MSP430x1xx Features
       ADDRESS MODES


              MODE            REP.                DESCRIPTION              EXAMPLE         Valid for


       Register                Rn     Data contained in Rn                MOV R10,R11       OyD

       Indexed                X(Rn)   Data in (Rn+X)                     MOV 2(R5),6(R6)    OYD

                                      Data in (PC+X) (X given by
       Symbolic               ADDR                                       MOV EDE, TONI      OYD
                                      assembler)

       Absolute               &ADDR   Data in address ADDR              MOV &EDE, &TONI     OYD


       Indirect ro Register   @Rn     Rn points to data                 MOV @R10,0(R11)       O

       Indirect and                   Rn points to data and increases
                              @Rn+                                      MOV @R10+,0(R11)      O
       automatic increase             after operation

       Inmediate               #N     Data is N                          MOV #45H,TONI        O




           International Summer Workshop on microbotics 2011
MSP430 TI
MSP430x1xx Features
       ADDRESS MODES




               TONI


               EDE
               MOV




        &EDE




                              TONI




         International Summer Workshop on microbotics 2011
MSP430 TI
MSP430x1xx Features
       ADDRESS MODES




         International Summer Workshop on microbotics 2011
MSP430 TI
MSP430x1xx Assembler
  DIRECTIVES

 -#include “namefile”
 -Eg. <msp430x1xx.h> and <intrinsics.h> (only C/C++)
 -”;”: Comment
 - ORG expr; eg. ORG $5000
 -label EQU expr; eg. PI EQU 3.14
 -DS8 size, DS16 size, DS32 size; eg. DS8 7
 -DB val, DW val, DL val; eg. DB 8
 -PUBLIC simbol, EXTERN simbol; ej. PUBLIC myvar EXTERN myvar
 -END




             International Summer Workshop on microbotics 2011
MSP430 TI
MSP430x1xx Assembler
  INSTRUCTIONS




          International Summer Workshop on microbotics 2011
MSP430 TI
MSP430x1xx Assembler
  INSTRUCTIONS




          International Summer Workshop on microbotics 2011
MSP430 TI
MSP430x1xx Assembler
  INSTRUCTIONS




          International Summer Workshop on microbotics 2011
MSP430 TI
MSP430x1xx Assembler
  INSTRUCTIONS (EMULATED)




          International Summer Workshop on microbotics 2011
MSP430 TI
MSP430x1xx Assembler
  INSTRUCTIONS (EMULATED)




          International Summer Workshop on microbotics 2011
MSP430 TI
MSP430x1xx Clock System




                                                              SIGNALS
       SOURCES




                 International Summer Workshop on microbotics 2011
MSP430 TI
    MSP430x1xx Clock System
    LFXT1
•   Low Frecuency: XTS=0 and XTL 32768Hz  Ultra low power comsumption
•   High Frecuency: XTS=1  enhanced processing speed
•   OFF MODE: OSCOFF=1 (LFXT1CLK can't be MCLK or SMCLK)




    XT2 (if available)

•   Equal to LFXT1 in HF mode




                   International Summer Workshop on microbotics 2011
MSP430 TI
    MSP430x1xx Clock System
    LFXT1




    XT2 (if available)

•   Equal to LFXT1 in HF mode




                   International Summer Workshop on microbotics 2011
MSP430 TI
            MSP430x1xx. Módulo de reloj
MSP430x1xx Clock System
      DCO
  •   RC Oscillator  frequency changes with T and V
  •   OFF MODE SCG0=1 (as long as it is not the source for MCLK o
      SMCLK)




 •    Digital Control 
          - Injected current DC  main frequency
           forced by resistor
          - DCOR chooses external or inner resistor
          - Control Rsel0 – Rsel2 => 8 values
          - Bits DCO0-DCO2 => adjust DCOCLK
          - Modulation Bits MOD0 – MOD4  stabilization

            International Summer Workshop on microbotics 2011
MSP430 TI
          MSP430x1xx. Módulo de reloj
MSP430x1xx Clock System
    DCO




          International Summer Workshop on microbotics 2011
MSP430 TI
         MSP430x1xx. Módulo de reloj
MSP430x1xx Power Consumption modes


                                        SCG       SCG        OSCO    CPUO
                   MODE
                                         1         0          FF      FF

              Active                      0         0            0    0
              Low Power 0                 0         0            0    1
              Low Power 1                 0         1            0    1
              Low Power 2                 1         0            0    1
              Low Power 3                 1         1            0    1
              Low Power 4                 1         1            1    1

             •     Bit CPUOFF: (0/1)  MCLK active/stopped
             Bit OSCOFF: (0/1)  LFXT1 active/stopped*
             Bit SCG0:(0/1)  GENERADOR DC active/stopped*
             Bit SCG1:(0/1)  SMCLK active/stopped*
                 *As long as not used for main clock signalsj.




         International Summer Workshop on microbotics 2011
MSP430x1xx InterruptionsMSP430 TI
         MSP430x1xx. Módulo                       de reloj



  1.   (depending on CPU state): Finish current instruction/exit LPC
  2.   Store PC in pile
  3.   Store SR in pile
  4.   Choose highest priority interruption
  5.   Reset interruption flag (if pertaining)
  6.   GIE=CPUOFF=SCG1=V=N=Z=C=0
  7.   Load interruption vector content on PC



                  Recover after RETI




              International Summer Workshop on microbotics 2011
MSP430 TI
          MSP430x1xx. Módulo de reloj
MSP430x1xx Interruptions




          International Summer Workshop on microbotics 2011

Microbots: microcontroller msp430

  • 1.
    Microcontrollers: The brainof the bot MSP430 Cristina Urdiales Departamento de Tecnología Electrónica Universidad de Málaga International Summer Workshop on microbotics 2011
  • 2.
    INTRODUCTION What is amicrocontroller? MICROPROCESSOR 0 MICROCONTROLLER International Summer Workshop on microbotics 2011
  • 3.
    INTRODUCTION What is amicrocontroller? TRADITIONAL CIRCUIT MICROCONTROLLER International Summer Workshop on microbotics 2011
  • 4.
    INTRODUCTION Types of microcontrollers ✔ GENERAL PURPUSE, LOW COST ✔ ULTRALOW POWER CONSUMPTION ✔ AVERAGE PERFORMANCE Ethernet, VGA, LCD, Touch-screen, etc… Standard architectures, Limited OS ✔ HIGH PERFORMANCE Linux, windows CE, … High graphic performance As powerful as a few years old PC ✔ DSPs ✔ MIXED ARCHITECTURE DSP+Microprocessors ✔ FPGAs Free Hardware International Summer Workshop on microbotics 2011
  • 5.
    INTRODUCTION Ultra low powerconsumption: Examples Devices of limited weight • Device fed with button battery (80 mAH). Average power consumption: 8 uA => 1,14 years Devices requiring long term operation: • Wireless sensor network: required life 8 years. Average power consumption 200 uA. => Battery required 15.000 mAH. International Summer Workshop on microbotics 2011
  • 6.
    INTRODUCTION Ultra low powerconsumption: Examples International Summer Workshop on microbotics 2011
  • 7.
    MSP430 TI 114 International Summer Workshop on microbotics 2011
  • 8.
    MSP430 TI International SummerWorkshop on microbotics 2011
  • 9.
    MSP430 TI MSP430x1xx Features • Ultra Low Power Consumption - Feeding range: 1,8 – 3,6 V - Several ULPC modes • Core: CPU RISC 16 bits - High processing performance - Memory optimization • High performance periferals: ADCs, TIMERs, USARTs, comparers, battery level indicators, I2C ... • Flexible clock system • JTAG integrated • Low cost - Development system around 50€ - Microcontrollers 1-3€ International Summer Workshop on microbotics 2011
  • 10.
    MSP430 TI MSP430x1xx Features ➢ Von Neumann architecture ➢ Data and Address buses: 16 bits ➢ Data format .B and .W International Summer Workshop on microbotics 2011
  • 11.
    MSP430 TI REGISTERS MSP430x1xx Features MEMORY MAP International Summer Workshop on microbotics 2011
  • 12.
    MSP430 TI MSP430x1xx Features ADDRESS MODES MODE REP. DESCRIPTION EXAMPLE Valid for Register Rn Data contained in Rn MOV R10,R11 OyD Indexed X(Rn) Data in (Rn+X) MOV 2(R5),6(R6) OYD Data in (PC+X) (X given by Symbolic ADDR MOV EDE, TONI OYD assembler) Absolute &ADDR Data in address ADDR MOV &EDE, &TONI OYD Indirect ro Register @Rn Rn points to data MOV @R10,0(R11) O Indirect and Rn points to data and increases @Rn+ MOV @R10+,0(R11) O automatic increase after operation Inmediate #N Data is N MOV #45H,TONI O International Summer Workshop on microbotics 2011
  • 13.
    MSP430 TI MSP430x1xx Features ADDRESS MODES TONI EDE MOV &EDE TONI International Summer Workshop on microbotics 2011
  • 14.
    MSP430 TI MSP430x1xx Features ADDRESS MODES International Summer Workshop on microbotics 2011
  • 15.
    MSP430 TI MSP430x1xx Assembler DIRECTIVES -#include “namefile” -Eg. <msp430x1xx.h> and <intrinsics.h> (only C/C++) -”;”: Comment - ORG expr; eg. ORG $5000 -label EQU expr; eg. PI EQU 3.14 -DS8 size, DS16 size, DS32 size; eg. DS8 7 -DB val, DW val, DL val; eg. DB 8 -PUBLIC simbol, EXTERN simbol; ej. PUBLIC myvar EXTERN myvar -END International Summer Workshop on microbotics 2011
  • 16.
    MSP430 TI MSP430x1xx Assembler INSTRUCTIONS International Summer Workshop on microbotics 2011
  • 17.
    MSP430 TI MSP430x1xx Assembler INSTRUCTIONS International Summer Workshop on microbotics 2011
  • 18.
    MSP430 TI MSP430x1xx Assembler INSTRUCTIONS International Summer Workshop on microbotics 2011
  • 19.
    MSP430 TI MSP430x1xx Assembler INSTRUCTIONS (EMULATED) International Summer Workshop on microbotics 2011
  • 20.
    MSP430 TI MSP430x1xx Assembler INSTRUCTIONS (EMULATED) International Summer Workshop on microbotics 2011
  • 21.
    MSP430 TI MSP430x1xx ClockSystem SIGNALS SOURCES International Summer Workshop on microbotics 2011
  • 22.
    MSP430 TI MSP430x1xx Clock System LFXT1 • Low Frecuency: XTS=0 and XTL 32768Hz  Ultra low power comsumption • High Frecuency: XTS=1  enhanced processing speed • OFF MODE: OSCOFF=1 (LFXT1CLK can't be MCLK or SMCLK) XT2 (if available) • Equal to LFXT1 in HF mode International Summer Workshop on microbotics 2011
  • 23.
    MSP430 TI MSP430x1xx Clock System LFXT1 XT2 (if available) • Equal to LFXT1 in HF mode International Summer Workshop on microbotics 2011
  • 24.
    MSP430 TI MSP430x1xx. Módulo de reloj MSP430x1xx Clock System DCO • RC Oscillator  frequency changes with T and V • OFF MODE SCG0=1 (as long as it is not the source for MCLK o SMCLK) • Digital Control  - Injected current DC  main frequency  forced by resistor - DCOR chooses external or inner resistor - Control Rsel0 – Rsel2 => 8 values - Bits DCO0-DCO2 => adjust DCOCLK - Modulation Bits MOD0 – MOD4  stabilization International Summer Workshop on microbotics 2011
  • 25.
    MSP430 TI MSP430x1xx. Módulo de reloj MSP430x1xx Clock System DCO International Summer Workshop on microbotics 2011
  • 26.
    MSP430 TI MSP430x1xx. Módulo de reloj MSP430x1xx Power Consumption modes SCG SCG OSCO CPUO MODE 1 0 FF FF Active 0 0 0 0 Low Power 0 0 0 0 1 Low Power 1 0 1 0 1 Low Power 2 1 0 0 1 Low Power 3 1 1 0 1 Low Power 4 1 1 1 1 • Bit CPUOFF: (0/1)  MCLK active/stopped Bit OSCOFF: (0/1)  LFXT1 active/stopped* Bit SCG0:(0/1)  GENERADOR DC active/stopped* Bit SCG1:(0/1)  SMCLK active/stopped* *As long as not used for main clock signalsj. International Summer Workshop on microbotics 2011
  • 27.
    MSP430x1xx InterruptionsMSP430 TI MSP430x1xx. Módulo de reloj 1. (depending on CPU state): Finish current instruction/exit LPC 2. Store PC in pile 3. Store SR in pile 4. Choose highest priority interruption 5. Reset interruption flag (if pertaining) 6. GIE=CPUOFF=SCG1=V=N=Z=C=0 7. Load interruption vector content on PC Recover after RETI International Summer Workshop on microbotics 2011
  • 28.
    MSP430 TI MSP430x1xx. Módulo de reloj MSP430x1xx Interruptions International Summer Workshop on microbotics 2011