S32K148 SPI issue with the DMA

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

S32K148 SPI issue with the DMA

1,538 Views
ahmed_elamir
Contributor I

Hello,

 

We are using S32k148 Dev board, We configure SPI0 as Slave using the DMA.

 

When the slave wants to send data to Master, It Trigers the master by GPIO pin, and when it finish it return this pin to high.

As the slave doesn't know in advance the length of the frame from the master, after the CS pin is switched off, the slave terminate the communication using the function LPSPI_DRV_SlaveAbortTransfer then copy the received data to local buffer.

Also at the start, the slave sends some data to the master (it is received by the master successfully).

 

We have an issue while send or receive, many frames are dropped and not captured by the slave. It shall be sent multiple times from the Master so that the slave capture it, however the Master send it correct.

 

SPI slave configuration

pastedImage_1.png

DMA controller configuration

pastedImage_3.png

pastedImage_5.png

 

We use master SPI clock of 6.25MHz. Is there any further configuration shall be done if we use the SPI with DMA ? 

 

 

Thanks for the help. 

Tags (1)
0 Kudos
6 Replies

1,233 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi,

Abort function clear RX/TX buffer, so if if you are calling abort when data is still in the hardware fifo you will miss some data. 

Probably you should add as workaround a busy waiting in your app to be sure that RX fifo is empty (RXCOUNT in FSR register) and only after this you can abort the transfer. LPSPI driver doesn't cover this use case with variable length transfers.

Best regards,

Razvan

0 Kudos

1,233 Views
ahmed_elamir
Contributor I

Hello Razvan,

Thanks a lot for your reply.

I configured the CS pin as an intrupt pin also, When it switchs to low (Which means that master sent all the data)  an ISR is Excuted for the CS pin, Inside it we first call the abort function then we copy the received data from the DMA buffer to a local buffer.

What you mean is that before call the abort function inside the CS ISR, We have to make sure that the RX buffer is empty first (all the Received data are copied to DMA buffer). Am I right?

0 Kudos

1,233 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi,

Yes, you are right. You have to make sure that RX buffer is empty.

Best regards,

Razvan

0 Kudos

1,233 Views
ahmed_elamir
Contributor I

Hello Razvan,

I tried your proposal to check the RX byes before abort the transmition, But still the same issue.

Also every time the size of the RX buffer = 0, So I seems that at the moment the abort function is called, there are no remaings bytes in the SPI RX buffer.

So I think the issue maybe not in the RX buffer, What do you think of ? 

0 Kudos

1,232 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi,

Could you share your project?

Razvan

0 Kudos

1,232 Views
ahmed_elamir
Contributor I

Hi,

Ok, I will try your proposal and feedback you.

Thanks for the help

0 Kudos