Hi TI team,
I am using spi protocol which involves imx8 as master and msp430fr5992 as slave.
MSP430FR5992 will receive some packet, do some processing and send back the processed data to imx.
We are able to receive 32 bytes(packets) from imx8 and process the data also. But we are not able to transmit 32 bytes at a time.
Below is the spi configuration:
void Spi_slave_init()
{
// Configure GPIO: SEL0+SEL1
P1SEL1 |= (BIT6); //USCI_B0 MOSI
P2SEL1 |= (BIT2); //USCI_B0 CLK
P1SEL1 |= (BIT7); //USCI_B0 MISO pin
P1SEL1 |= (BIT3); //Chip Select Pin
P1SEL0 &= ~(BIT6); //USCI_B0 MOSI
P2SEL0 &= ~(BIT2); //USCI_B0 CLK
P1SEL0 &= ~(BIT7); //USCI_B0 MISO pin
P1SEL0 &= ~(BIT3); //Chip Select Pin
PJSEL0 |= BIT4 | BIT5;
// Configure USCI_B0 for SPI operation
UCB0CTLW0 = UCSWRST; // **Put state machine in reset**
// 4-pin, 8-bit SPI slave
UCB0CTLW0 |= UCSYNC | UCCKPL | UCMSB | UCMODE_2 ; // Clock polarity high, MSB
UCB0CTLW0 &= ~UCCKPH; // Clock Phase = LOW
UCB0CTLW0 |= UCSSEL_0; //UCLK for slave mode
UCB0CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**
UCB0IE |= UCRXIE; // Enable USCI_B1 RX interrupt
}
This is how we are receiving the packet:
for( index_spi=0; index_spi<MAX_SPI_FRAME ; index_spi++) //MAXIMUM_SPI_FRAME
{
while(!(UCB0IFG & UCRXIFG)){};
SPIRxData[index_spi]= UCB0RXBUF; //Storing the data received from receive buffer into an array
UCB0IFG &= ~UCRXIFG;
}
This is how we are transmitting the processed data:
for(index_tx=0; index_tx< TxLength; index_tx++) //Decide how many bytes to transmit based upon Txlength
{
while(!(UCB0IFG & UCTXIFG)){};
UCB0TXBUF = SPI_TXData[index_tx]; // Transmit data to imx
}
In this transmit function we are able to transmit only one byte. We are not able to send the entire packet. We are able to send the entire packet at the time when we are receiving the next packet.
If any solution you have to transmit the entire packet at a time let me know.
Regards
Abhisek