S32K146 LPSPI Example problem

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

S32K146 LPSPI Example problem

跳至解决方案
1,712 次查看
f_gaudon
Contributor II

Hi,

I've got some problems with the LSPSI example.

Before sending a SPI trame my TX and RX fifo counter are 0 . 

f_gaudon_0-1651741411403.png

 

After executing the ligne : LPSPI1->TDR = send; the RX counter has incremented to 1 but not the TX fifo counter ? Can someone explain me why ?

f_gaudon_0-1651741704521.png

 

Besides that, I do not understand the ligne : LPSPI1->SR |= LPSPI_SR_TDF_MASK; /* Clear TDF flag */

Because in the RM, this bit seems not writable.

f_gaudon_1-1651741552995.png

Thanks for your time and answers,

Florian

 

 

 

 

标记 (5)
0 项奖励
回复
1 解答
1,652 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Florian,

  • The 16bit frame written to the TX FIFO goes to the TX shift register and is sent out. Meanwhile, an RX frame is received. That's why you see the frame in the RX FIFO but not in the TX FIFO.

 

  • If you don't want to read the RX data, you can set the RXMSK bit in the command (TCR)

 

  • Regarding the RDF, TDF clearing process, you are right, the example is not correct. The flags cannot be cleared by w1c.They get cleared automatically depending on the number of frames in the FIFOs and RXWATER / TXWATER thresholds.

 

BR, Daniel

 

 

 

 

 

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,681 次查看
f_gaudon
Contributor II

I'm sending a SPI frame every second, the first start correctly but after few seconds, the RX fifo is full (nothing is connected on the SDIN pin) and the CS stay low after sending the last frame.

In the example, the flags cleared are in Read only mode, I still don't get it. 

0 项奖励
回复
1,653 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Florian,

  • The 16bit frame written to the TX FIFO goes to the TX shift register and is sent out. Meanwhile, an RX frame is received. That's why you see the frame in the RX FIFO but not in the TX FIFO.

 

  • If you don't want to read the RX data, you can set the RXMSK bit in the command (TCR)

 

  • Regarding the RDF, TDF clearing process, you are right, the example is not correct. The flags cannot be cleared by w1c.They get cleared automatically depending on the number of frames in the FIFOs and RXWATER / TXWATER thresholds.

 

BR, Daniel

 

 

 

 

 

0 项奖励
回复
1,627 次查看
f_gaudon
Contributor II

Hi Daniel,

Thanks for your answer, I understood I was receiving some frames on RX so I was reading them just to clear the RXFIFO. But the RXMSK bit you suggested seems to be a better option !

Thanks again

Florian

0 项奖励
回复