MSP430_C7_Course Lesson1_MCU

download MSP430_C7_Course Lesson1_MCU

of 35

Transcript of MSP430_C7_Course Lesson1_MCU

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    1/35

    http://s653.photobucket.com/albums/uu259/rockc4/FanLED/?action=view&current=mat_1-Copy.png
  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    2/35

    CU LC B NGHIN CU KHOA HC KHOA IN-IN THBCHKHOA TP. H CH MINH

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    3/35

    1 MCUs & MSP430G2553

    2

    C programming & IDE CCS v5.2

    3 GPIO in MSP430

    4 Discussion & Homework

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    4/35

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    5/35

    Requirement:

    a. Blink a LED every 1s

    b. Turn on a led when button is pushed

    c. Timer, ADC, UART, Interrupt, SPI, I2C

    d.

    .

    Solution: M icro Control ler Unit

    - Integrated circuits

    - Programmable

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    6/35

    Core:

    8b, 16b,

    32b,64b

    GPIO

    Timer

    ADC

    UART

    SPI

    P:MSP430, 8051,PIC,ARM,

    Peripherals

    C:

    MSP430, LPC1114,

    PIC16F887,

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    7/35

    - Simple:hardware & software

    - Enough:price ,peripherals,

    - Developing TI Vietnam

    16kB Flash

    512B RAM

    2 Timer_A3s 8 Ch. Comp_A+ 8 Ch. ADC10

    USCI

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    8/35

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    9/35

    http://www.ti.com/product/msp430g2553

    http://www.ti.com/product/msp430g2553http://www.ti.com/product/msp430g2553http://www.ti.com/product/msp430g2553
  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    10/35

    Package:

    TSSOP: 20 Pin, 28 Pin

    PDIP: 20 Pin

    QFN: 32 Pin

    Low Supply-Voltage Range

    o 1.8 V to 3.6 V

    Ultra-Low PowerConsumption

    16-Bit RISCArchitecture, 62.5-ns Instruction Cycle Time

    Basic Clock Module Configurationso Internal Frequencies up to 16 MHz With Four Calibrated Frequency

    o Internal Very-Low-Power Low-Frequency (LF) Oscillator

    o 32-kHz Crystal

    o External Digital Clock Source

    http://www.ti.com/product/msp430g2553

    Quad flat no lead: dn

    Plastic dual in-line package:2 hng

    Thin shrink small outline package

    http://www.ti.com/product/msp430g2553http://www.ti.com/product/msp430g2553http://www.ti.com/product/msp430g2553
  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    11/35

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    12/35

    Embedded Emulation

    6-pin eZ430

    Connector

    Part and Socket

    Crystal Pads

    Power Connector

    Reset ButtonLEDs and Jumpers

    P1.0 & P1.6

    P1.3 Button

    Chip

    Pinouts

    USB Emulator

    Connection

    http://www.ti.com/tool/msp-exp430g2

    http://www.ti.com/tool/msp-exp430g2http://www.ti.com/tool/msp-exp430g2http://www.ti.com/tool/msp-exp430g2http://www.ti.com/tool/msp-exp430g2http://www.ti.com/tool/msp-exp430g2
  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    13/35

    MCUDebugger

    Debugger

    MCU

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    14/35

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    15/35

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    16/35

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    17/35

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    18/35

    Integrated development environment for TI embedded

    processors Includes debugger, compiler, editor, simulator, OS

    The IDE is built on the Eclipse open source software framework

    Extended by TI to support device capabilities

    Integrate additional tools OS application development tools (Linux, Android)

    Code analysis, source control

    Linux support

    Low cost! $445 or $495 (!) -> Free code size limited for students

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    19/35

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    20/35

    MSP430G2553

    CCS IDE

    General

    PurposeInput/

    Output

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    21/35

    - Main MSP430G2553

    - Chunb CCS, datasheet- Tuts : to project, GPIO

    - Main MSP430G2553

    - IDE

    - GPIO

    - Nhy Led- Nt nhn-LCD

    - Keypad

    -Led matrix

    -Led 7 segment

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    22/35

    Cc Thanh ghi ny qui nhch lm vic cho cc chn bao gmPxSEL v PxSEL2

    VD: Ta mun port 1 l GPIO th ta thchinlnhnh sau:

    P1SEL = 0;P1SEL2 = 0;

    Lu : Interrupts P1 v P2 sb v hiu ha khi PxSEL=1

    (!) Xem thm Datasheet: Port Schematics

    0 0

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    23/35

    Thanh ghi ny qui nhloi ng vo ra cho ccchn GPIO

    Mcnhttc cc chn l input (0),khi cni thnh output (1), ta t

    Bit tngng trn thanh ghi l 1.

    VD: P1DIR = 0x01 //pin P1.0 is output

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    24/35

    Thanh ghi ny cho php tt hoc m ch

    pullup/pulldown resistor cho cc chn GPIO.Mcnh cc bit ca thanh ghi ny l 0.

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    25/35

    Khi ta cnc gi trt cc chn GPIO input, ta sc

    bit tngng trn thanh ghi PxIN

    Lu l ta phi chc rng bit tngng ca GPIOtrn thanh ghi PxDIR vn l 0 (input) trc khicPxIN.

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    26/35

    Khi ta munxutin p trn cc chn Output, ta st gi

    trtngng vo cc thanh ghi PxOUT (logic 1 -> VCC, logic0 -> 0V)

    Trong trnghp thanh ghi PxREN qui nhGPIO chpullup/pulldown resistor th PxOUT qui nh:

    Lu l ta phi chc rng bit tng ng ca GPIO trnthanh ghi PxDIR c set l 1 (output) trc khixutmclogic ra.

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    27/35

    thchinxut/nhp trn 1 chn (Pin):

    - tng gi tr cho thanh ghi PxDIR: 1:output; 0: input- tchcnngca pin l GPIO hay cc chcnng khc quathanh ghi PxSEL

    - Xut tn hiubng cch ghi gi tr0hoc1 vo thanh ghiOUT ca port tngng (vd: P1OUT)- c gi trca chn bng cch cmc logic trn thanh ghiIN ca port tngng (vd: P1IN)

    - Khi cnintr ko ln/xung, tng gi trca bit trncc thanh ghi PxREN v PxOUT

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    28/35

    #include

    // hay //Khai bo bin ton ccunsigned int a

    //Khai bo chng trnh convoid chuong_trinh_con(void)

    {

    //chng trnh con y}

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    29/35

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    30/35

    #define BIT0 (0x0001)

    #define BIT1 (0x0002)#define BIT2 (0x0004)

    // . .

    #define BITE (0x4000)

    #define BITF (0x8000)

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    31/35

    Pin: low level --> LED On

    Pin: high level --> LED Off

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    32/35

    //Blink a led connected with P1.0

    #include // or

    void main(void)

    {

    // unsigned int i; // declare variables

    WDTCTL = WDTPW + WDTHOLD; // Stop watch dog timerP1DIR |= BIT0 + BIT6; // Set P1.0 and P1.6 to output direction

    while(1)

    {

    P1OUT ^= BIT0 + BIT6; // Toggle P1.0 and P1.6 using exclusive-OR

    __delay_cycles(1000000); // Delay 1000000 Machine Cycles (MC=1us)// in IAR: _delay_cycles(1000000);

    }

    }

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    33/35

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    34/35

    LED 7 Segment

    LED matrix 8x8

    LCD 16x2

    Keypad 4x4

  • 7/27/2019 MSP430_C7_Course Lesson1_MCU

    35/35