Implementing always-ready SPI slave with S32K and FreeRTOS

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

Implementing always-ready SPI slave with S32K and FreeRTOS

Jump to solution
1,214 Views
yfliu
Contributor IV

Dear community members,

I am wondering how we can implement an always-ready SPI slave with S32K14x MCU and FreeRTOS?

By "always-ready" means that whenever the SPI master starts a duplex transfer by toggling the CS line, the MCU can respond immediately with data in an outgoing queue.

I am considering to have an ISR triggered by the CS line, within the ISR we initiate a SPI slave xfer using SPI device or PAL driver. But I am unsure if the ISR can respond fast enough? Should we ask the SPI master side to wait a while before sending the SCLK signals after toggleing the CS line?

If this works in general, what details should we watch (e.g. ISR priority etc)?

 

Regards,

yf

 

 

0 Kudos
1 Solution
1,162 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Yanfeng,

Looking at the callbacks.h header file, there is no TDF callback event just the SPI_EVENT_END_TRANSFER.

danielmartynek_0-1629121601318.png

 

Regards,

Daniel

View solution in original post

0 Kudos
3 Replies
1,163 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Yanfeng,

Looking at the callbacks.h header file, there is no TDF callback event just the SPI_EVENT_END_TRANSFER.

danielmartynek_0-1629121601318.png

 

Regards,

Daniel

0 Kudos
1,178 Views
yfliu
Contributor IV

Hi @danielmartynek

 

Thank you for the design idea and sorry for my late reply.

Do you think if I can acheive the above idea using SPI_PAL library? or I have to use low-level drivers library?

I am wondering if I can use `SPI_SlaveTransfer()` within the TDF ISR callback?

Regards,

Yanfeng

 

 

0 Kudos
1,198 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @yfliu,

Please refer to the description of the transmit FIFO in the Slave mode:

danielmartynek_0-1628076835533.png

I think the best solution is to fill the transmit FIFO whenever the number of words in the FIFO drop below a certain level.

danielmartynek_1-1628076964137.png

 

Regards,

Daniel

 

 

0 Kudos