S32K144 LPSPI Rx FIFO issue

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

S32K144 LPSPI Rx FIFO issue

988 次查看
kentseng
Contributor II

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 */
}

标记 (5)
0 项奖励
1 回复

786 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hello kentseng,

I have difficulties to understand the issue.

Do you read the RX FIFO of the master? The FSR register provides the number of words stored in the RX FIFO.

The master stall the operation when the receive FIFO is full unless CFGR1_NOSTALL is set.

Do you see any errors in the LPSPI_SR register?

Could you please attach a test project?

Thank you,

BR, Daniel

0 项奖励