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.

MSP432P401R: MSP432 as a slave spi communication problem

Part Number: MSP432P401R

Hello everyone,

     I am trying to communicate between  MSP432 (as Slave) and TMS320F28027-C2000 launchpad(as  Master) via SPI.

- SPI slave (msp432)  talks to SPI master(f28027) using 4-wire mode with slave select enabled. in the code, master transmit 0x81 data to slave. If Data received from master is 0x81 then slave will transmit 0x88 to master else transmit 0xAA.

    when i debug the code msp432 can not receive the data 0x81 instead of it receive dummy data 0xFF and transmitt 0xFF also.when i pause the code data transmit in buffer is 0xAA is right because condition is not satisfied. But on oscilloscope, it shows 0xFF on MISO line.

I am attaching a code for reference:-

MSP432P401R(slave):-

static uint8_t RXDATA = 0;

void InitSPI(void)
{
P10->SEL0 |= BIT0 | BIT1 | BIT2 | BIT3; // set 4-SPI pin as second function

EUSCI_B3->CTLW0 |= EUSCI_B_CTLW0_SWRST; // Put state machine in reset
EUSCI_B3->CTLW0 = EUSCI_B_CTLW0_SWRST |
EUSCI_B_CTLW0_SYNC | // Synchronous mode
EUSCI_B_CTLW0_CKPL | // Clock polarity high
EUSCI_B_CTLW0_MSB | // MSB first
EUSCI_B_CTLW0_MODE_1 | // 4-pin SPI mode
EUSCI_B_CTLW0_STEM ; // STE mode select
EUSCI_B3->CTLW0 |= EUSCI_B_CTLW0_SSEL__SMCLK; // ACLK
EUSCI_B3->BRW = 0x01; // /2,fBitClock = fBRCLK/(UCBRx+1).
EUSCI_B3->CTLW0 &= ~EUSCI_B_CTLW0_SWRST;// Initialize USCI state machine
EUSCI_B3->IE |= EUSCI_B_IE_RXIE; // Enable USCI_B3 RX interrupt


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

}

// SPI interrupt service routine
void EUSCIB3_IRQHandler(void)
{
if (EUSCI_B3->IFG & EUSCI_B_IFG_RXIFG)
{
// USCI_B0 TX buffer ready?
while (!(EUSCI_B3->IFG & EUSCI_B_IFG_TXIFG));

// Echo received data
RXDATA=EUSCI_B3->RXBUF;

if (RXDATA==0x81)
{
// USCI_B0 TX buffer ready?
while (!(EUSCI_B3->IFG & EUSCI_B_IFG_TXIFG));

// Echo received data
EUSCI_B3->TXBUF = 0x88;
}
else
{
// USCI_B0 TX buffer ready?
while (!(EUSCI_B3->IFG & EUSCI_B_IFG_TXIFG));

// Echo received data
EUSCI_B3->TXBUF =0xAA;
}
// Clear the receive interrupt flag
EUSCI_B3->IFG &= ~EUSCI_B_IFG_RXIFG;

}
}

F28027(Master):-

uint16_t rdata;         // received data       
         sdata=0x81;
         SpiaRegs.SPICTL.bit.TALK = 1; // Enable Transmit path
         spi_xmit(sdata << 8);// Master transmits data
         while(SpiaRegs.SPISTS.bit.BUFFULL_FLAG == 1); // Waits until data rx’d
         dummy = SpiaRegs.SPIRXBUF;
         delay_loop();
         SpiaRegs.SPICTL.bit.TALK = 0;
          // Disable Transmit path
         while(SpiaRegs.SPISTS.bit.BUFFULL_FLAG == 1);
         spi_xmit(sdata << 8); // Send dummy to start tx
         // NOTE: because TALK = 0, data does not tx onto SPISIMOA pin
         while(SpiaRegs.SPISTS.bit.INT_FLAG !=1) {} // Wait until data received
         rdata = SpiaRegs.SPIRXBUF;
         rdata=rdata<<8; //
         delay_loop();
F28027 is successfully transmit the value 0x81 as i checked it on DSO. Why data 81 is not received in msp432??

 

  • > EUSCI_B_CTLW0_MODE_1 | // 4-pin SPI mode

    This specifies STE (Chip Select) as Active High (per SLAU356H Table 25-12; MODE_2 would be active low). I can't say this is wrong, but it is unusual. Is this the way the master is configured?
  • Hello Sayali, Can you comment or provide any feedback if the polarity of the chip select is correct?

    Regards,
    Chris

**Attention** This is a public forum