Hi support,
I configured RM42 SPI1 as a SPI slave, and use AM65x MCU as the SPI master. The two boards are connected with SOMI, SIMO, CLK, CS and GND.
AM65x MCU will loop reading SPI from the RM42 board on start up.
If AM65X board boots up earlier than the RM42 board, everything seems to be fine. But if RM42x board boots earlier, it will be stuck in the function spiTransmitAndReceiveData.
Below is the code RM42 SPI slave:
// SPI
spiInit();
for (;;) {
// Transmit SPI
spiTransmitAndReceiveData(spiREG1, &dataconfig1_t, 16, spiTxData, spiRxData);
// Toggle LED when success
gioToggleBit(gioPORTA, 2);
}
When it's stuck, it stays in the endless loop in the function spiTransmitAndReceiveData which is in the spi.c file:
/*SAFETYMCUSW 28 D MR:NA <APPROVED> "Hardware status bit read check" */
while((spi->FLG & 0x00000100U) != 0x00000100U)
{
} /* Wait */
The value of the spi->FLG is 0x201, sometime it's 0x211.
When this happens, if I recycle the power of the RM42 board, which makes it boot after the AM65x board, it will then work fine.
So what could be the problem? And how to clear the error and jump out of the endless loop?