S32K146 LPSPI Example problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K146 LPSPI Example problem

Jump to solution
1,245 Views
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

 

 

 

 

0 Kudos
1 Solution
1,185 Views
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

 

 

 

 

 

View solution in original post

0 Kudos
3 Replies
1,214 Views
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 Kudos
1,186 Views
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 Kudos
1,160 Views
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 Kudos