AnsweredAssumed Answered

S32K144 LPSPI Rx FIFO issue

Question asked by Tzu Kuan Tseng on Aug 23, 2019
Latest reply on Aug 27, 2019 by Daniel Martynek

Dear Sir.

 

I design a BMS with S32K144 and MC33664,

so I should open LPSPI0 (Master)and LPSPI1 (Slave),

TPL communication once 5 bytes,

 

after transmit 40-bit data, LPSPI1 using "while((LPSPI1->SR & LPSPI_SR_RDF_MASK)>>LPSPI_SR_RDF_SHIFT==0);"

but in the debug mode , MCU will stop on here. i have no ideal for this.

and how to read the Rx FIFO, if over 1 word.i just read the last 32bits

 

u32 SPIRxReadBytes(u8 *u8Data, u8 maxBytes)
{
u32 u8BytesRead;
u8BytesRead = 0;
u8Data = u8Data+maxBytes; // set pointer to end of buffer
while((LPSPI1->SR & LPSPI_SR_RDF_MASK)>>LPSPI_SR_RDF_SHIFT==0);
/* Wait at least one RxFIFO entry */
u8BytesRead= LPSPI1->RDR; /* Read received data */
LPSPI1->SR |= LPSPI_SR_RDF_MASK; /* Clear RDF flag */


return u8BytesRead; /* Return received data */
}

Outcomes