This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS: MSP432P401R SPI Examples

Other Parts Discussed in Thread: MSP430G2553

Tool/software: Code Composer Studio

i am not getting how to do SPI PROGRAMMING in msp432 ..plz suggest me with example if possible..i am using msp432 as a slave to my msp430(master) plz help

  • Resource explorer is a great source for code examples on this!

    Are you using CCS? You can go to View->Resource Explorer, select the project you want and then download it directly into CCS.  Very easy way to import and test code examples on your device.  You might also look for CCS cloud (there is a cloud icon you can press in the upper right hand corner of the project window in the links I send) which makes importing these examples super simple/fast.

    OK, so a good place to start is with msp432p401x_euscib0_spi_10 and msp430g2xx3_uscia0_spi_09.  It will likely take a little bit of manipulation to make them work together and to give you an output you can easily interpret as correct or not (if you do not use logic analyzer).

    Please reference this as a starting point and do not hesitate to ask me questions regarding these examples.

  • i have few question initially,
    1)-IN slave microcontroller msp432
    EUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_SSEL__ACLK; // ACLK
    EUSCI_B0->BRW = 0x01; // /2,fBitClock = fBRCLK/(UCBRx+1).
    EUSCI_B0->CTLW0 &= ~EUSCI_B_CTLW0_SWRST;// Initialize USCI state machine
    EUSCI_B0->IE |= EUSCI_B_IE_RXIE; // Enable USCI_B0 RX interrupt
    what is the use of BRW ?
    2)- If i simply want to send a data (0x01) from msp430 to msp 432,( considering any port pin )what changes i gonna make in slave side referring to this example(msp432p401x_euscib0_spi_10)?
  • sachin bankoti said:
    i have few question initially,
    1)-IN slave microcontroller msp432

    I will explain a little about this, but my advice will be to read the Technical Reference Manual to learn more about it and to see more detailed descriptions.  This is one of the best tools there is for learning about our MSP devices along with the datasheet; links to both of these can be found on the part's homepage.
    EUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_SSEL__ACLK; // ACLK  
    EUSCI_B0->BRW = 0x01; // /2,fBitClock = fBRCLK/(UCBRx+1).    
    EUSCI_B0->CTLW0 &= ~EUSCI_B_CTLW0_SWRST;// Initialize USCI state machine  
    EUSCI_B0->IE |= EUSCI_B_IE_RXIE; // Enable USCI_B0 RX interrupt
    what is the use of BRW ?   How much to divide the input clock by. (bit clock prescaler).  The bit clock is ACLK in this case, and it does not need prescaling, so it is divided by one (1).
    2)- If i simply want to send a data (0x01) from msp430 to msp 432,( considering any port pin )what changes i gonna make in slave side referring to this example(msp432p401x_euscib0_spi_10)?    I think your question is too vague.  There are many things you can choose to do with the value received on the slave side depending on your application needs.  To be more specific though, I would say you could create a variable in which to store EUSCI_B0->RXBUF into instead of just passing it back to the TXBUF as the example does (line 126).  Maybe create a while loop in the end of the main and remove line 101 so that the device doesn't sleep on exit of the ISR.  Then do some processing on the variable inside of that while loop to turn on or off some LEDs or something simple like this to start with and then just let your imagination take you from there.

    My answers are added in red above.  Hopefully this is helpful to you.  Goodluck!

  • Hello sir,

    i have done my programming and i am able to transmit the data sucessfull from master(msp430) to slave msp(432)

    but i want only a single bit of data to be passed on rather then the continous data(because i an doing it for specific application)

    my program include

    1)- if the value (0x01) is transmitted from master to slave, and received in the slave terminal then , i have used a if condition and if the data received in slave is (0x01) then led will blink(p2.0) in msp 432

    2)- everthing is working properly, but i just want the led to blink once only, rather then continous data transfer .. plz sugest me sir.

    My master program is:-

    /*--------------------------------------------------------------------------------
    MASTER MSP 430G2553
    MSP430g2553 Master MSP432P401x Slaves
    // ----------------- -----------------
    // /|\| | /|\| |
    // | | | | | |
    // --|RST | --|RST |
    // | | | |
    // | | Data In (UCB0SIMO) | |
    // | P1.0|------------------->|P1.6 |
    // | | | |
    // | | Data OUT (UCB0SOMI)| |
    // | P1.2|<-------------------|P1.7 |
    // | | | |
    // | | S Clock (UCB0CLK) | |
    // | P1.4|------------------->|P1.5 |
    // | | | |
    ------------------------------------------------------------------------------------*/
    #include <msp430.h>
    volatile char received_ch = 0;
    int main(void)
    {
    //// P1OUT |= BIT5;
    // P1DIR |= BIT5;
    P1SEL = BIT1 | BIT2 | BIT4;
    P1SEL2 = BIT1 | BIT2 | BIT4;

    UCA0CTL1 = UCSWRST;
    UCA0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master
    UCA0CTL1 |= UCSSEL_2; // SMCLK
    UCA0BR0 |= 0x02; // /2
    UCA0BR1 = 0; //
    UCA0MCTL = 0; // No modulation
    UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**

    // P1OUT &= (~BIT5); // Select Device

    while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
    UCA0TXBUF = 0x01; // Send 0xAA over SPI to Slave
    // P1OUT |= (BIT5); // Unselect Device
    }

    //---------------------------------------------------------------------------------------------------------------------------------------------------

    my slave program is:--

    //---------------------------------------------------------------------------------------------------------------------------------------------------

    /*****************************************************************************
    * msp 432 slave
    * ids system
    * pin connection
    * MSP430g2553 Master MSP432P401x Slaves
    // ----------------- -----------------
    // /|\| | /|\| |
    // | | | | | |
    // --|RST | --|RST |
    // | | | |
    // | | Data In (UCB0SIMO) | |
    // | P1.0|------------------->|P1.6 |
    // | | | |
    // | | Data OUT (UCB0SOMI)| |
    // | P1.2|<-------------------|P1.7 |
    // | | | |
    // | | S Clock (UCB0CLK) | |
    // | P1.4|------------------->|P1.5 |
    // | | | |
    //
    ******************************************************************************/
    #include "msp.h"
    volatile unsigned int RXData,w;
    void loop_1();
    int main(void)
    {
    WDT_A->CTL = WDT_A_CTL_PW | // Stop watchdog timer
    WDT_A_CTL_HOLD;
    P2->DIR |= BIT0; // P1.0 set as output

    P1->SEL0 |= BIT5 | BIT6 | BIT7; // Set P1.5, P1.6, and P1.7 as
    // SPI pins functionality

    EUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_SWRST; // Put state machine in reset
    EUSCI_B0->CTLW0 = EUSCI_B_CTLW0_SWRST | // Keep the state machine in reset
    EUSCI_B_CTLW0_SYNC | // Set as synchronous mode
    EUSCI_A_CTLW0_CKPL | // Set clock polarity high
    EUSCI_B_CTLW0_MSB; // MSB first and Slave

    EUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_SSEL__ACLK; // ACLK
    EUSCI_B0->BRW = 0x01; // /2,fBitClock = fBRCLK/(UCBRx+1).
    EUSCI_B0->CTLW0 &= ~EUSCI_B_CTLW0_SWRST;// Initialize USCI state machine
    EUSCI_B0->IE |= EUSCI_B_IE_RXIE; // Enable USCI_B0 RX interrupt

    // Remain in LPM on exit from ISR
    // SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;

    // Ensures SLEEPONEXIT takes effect immediately
    // __DSB();

    // Enable global interrupt
    __enable_irq();

    // Enable eUSCI_B0 interrupt in NVIC module
    NVIC->ISER[0] = 1 << ((EUSCIB0_IRQn) & 31);

    // Enter LPM0
    // __sleep();
    // __no_operation();
    }
    //------------------------------------------------------------------------------------
    // SPI interrupt service routine
    void EUSCIB0_IRQHandler(void)
    {
    // Wait till a character is received
    while (!(EUSCI_B0->IFG & EUSCI_B_IFG_RXIFG));
    RXData = EUSCI_B0->RXBUF;
    if(RXData==0x01)
    {
    P2->OUT ^= BIT0; // XOR P2.0
    NVIC->ISER[0] = ~(1 << ((EUSCIB0_IRQn) & 31));

    // for (w = 200000; w > 0; w--); // Delay
    loop_1();
    }
    //----------------------------------------------------------------------------------------
    void loop_1()
    {
    EUSCI_B0->IFG &= ~EUSCI_B_IFG_RXIFG;
    }

  • Does the master code have a eUSCI ISR that you have omitted here? Or is this the complete Master code?
    What is the result (output) of this setup right now? Is the LED blinking continuously?

    I think where you are changing the NVIC inside of the 432 ISR is not proper: 1. you use "=~" where I think you mean "&=~" . 2. Referencing Section 2.4.3.1 in the TRM, I do not think you can write zeros to this register.
  • YES the led is blinking continously...still
    i am thinking of u using interrupt ..can u suggest any alternative

**Attention** This is a public forum