SPI on S32K148EVB-Q176

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

SPI on S32K148EVB-Q176

599 Views
andyknitt
Contributor II

I'm struggling to get SPI working on the S32K148EVB-Q176 eval board.

Matlab R2020a, Mode-Based Design Toolbox 4.2.4

I have an external SPI peripheral that I'm attempting to communicate with using SPI1.

I have modified the SPI Master example to match the pinout and configuration of the S32K148EVB-Q176 and have added a couple additional GPIO LED blink blocks from other examples to ensure that the model is executing as intended.

The blue LED (constant blinking) and red LED (toggle based in interrupt from button) are both working correctly (so the model is executing and interrupts are working), but the green LED (SPI transfer END interrupt) never comes on.  I don't see any level changes on any of the clock, data, or chip select pins on an oscilloscope.  CS is held high, CLK is held low, MOSI (PTA27) is held high, MISO (PTA29) is low.  If I remove the SPI blocks from the model, all of these pins remain low during execution.  

So it seems as though the SPI1 instance is being initialized successfully, but data transfers are not occurring.  

I'm not sure what I might be missing.  Any assistance in getting the data transfers to occur would be appreciated.  Model is attached.

andyknitt_0-1670001517594.png

andyknitt_1-1670001528286.png

 

 

0 Kudos
3 Replies

530 Views
andyknitt
Contributor II

As it turns out, the SPI on the S32K142 only works when I have the "Transfer Size" set to 8 bits in the LPSPI Config block.  If I set "Transfer Size" to 16 it doesn't seem to work.  

Is there something else I need to do to get 16 bit SPI working?

0 Kudos

528 Views
andyknitt
Contributor II

Actually it looks like if I set "Frame Size" to 8 bits and then feed the transmit block a vector of two uint8_t values with "Continuous Transfer" enabled, it sends the two 8 bit values as a single 16 bit transmission, which I think will work for what I need.

andyknitt_0-1671491366343.png

What then is the purpose of the "Transfer Size" or "Frame Size" parameter in the SPI configuration block?  I think I must be misunderstanding what that parameter is for.

andyknitt_1-1671491431192.png

 

0 Kudos

576 Views
andyknitt
Contributor II

As a follow up on this, I was able to get SPI working on an S32K142.  I'm still trying to understand what I might be doing incorrectly on the S32K148.

0 Kudos