đây là code e dùng SPI để con led 7 đoạn thứ nhất nhảy số từ 0-->9. mà nó không chạy đc. a xem dùm e với!!!
 
#include <msp430.h>
void Config_SPI_A(void);
void Send_byte_A(int data, int time_ms);
void Config_SPI_A(void) // Config module SPI USCIA
{
    //Config PIN
    P1SEL |= BIT2;
    P1SEL2 |= BIT2;
    //Config SPI
    UCA0CTL0 |= UCCKPL + UCMSB + UCMST + UCSYNC;
    UCA0CTL1 |= UCSSEL_2;                     // SMCLK
 
    UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
 
    UCA0BR0 |= 0x02;                          // f/2    for your choice
    UCA0BR1 = 0;                              //
 
    UCA0MCTL = 0;                             // No modulation
 
     IE2 |= UCA0TXIE;                          // Enable USCI0 RX interrupt
    __delay_cycles(75);                       // Wait for slave to initialize
}
void Send_byte_A(int data, int time_ms)     // Send 1 byte for module SPI USCIA
{
      int i_delay;
      while (!(IFG2 & UCA0TXIFG));          // USCI_A0 TX buffer ready?
      UCA0TXBUF = data;                     // Send next value
      for (i_delay = 0; i_delay<time_ms; i_delay++ )
      {
        _delay_cycles(1000);
      }
}
/*
 * main.c
 */
void main(void)
{
    WDTCTL = WDTPW | WDTHOLD;// Stop watchdog timer
    P2DIR=BIT0; P2SEL=0; P2SEL2=0; P2OUT=~BIT0;
    int i=0;
    int b[10]={0x14,0xD7,0x4C,0x2C,0x8D,0x25,0x24,0x57,0x04,0x05};
        Config_SPI_A();
        P1DIR |= BIT4;
        while(1)
        {
            Send_byte_A(b
, 1000);
            P1OUT &= ~BIT4;
            __delay_cycles(2000);
            P1OUT |= BIT4;
            i++;
            if(i==10)
            {
                i = 0;
            }
        }
}