S32K148 SPI Slave Mode Example

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

S32K148 SPI Slave Mode Example

2,173 Views
RahulL
Contributor I

Can anyone provide an example code for the SPI slave mode? The Design Studio only has code for Master mode configuration. I have trouble in setting the configuration registers and using the PCS (chip select) pins.

Tags (1)
0 Kudos
Reply
5 Replies

2,141 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

I have found some simple example on the following thread, apparently tested by my colleague.

https://community.nxp.com/t5/S32K/SPI-configuration-master-slave-S32K148/m-p/863053

Hope it helps

 

0 Kudos
Reply

2,120 Views
RahulL
Contributor I

Hi David,

Sorry for the delay, I have checked the example code suggested by you.

In my application, I am using S32K148 Eval board as a master SPI device and a 20 X 4 LCD (NHD-0420D3Z-FL-GBW-V3) as a SPI slave device. In the application I am using the same LPSPI1_init_master() function given in the example to initialize the S32K148 as a master device.

In the application, I am trying to display characters on the LCD. When I run the application in debug mode (by using step into, step over options) I am able to print the characters on the LCD without any issues. But when I am trying to do it in free run, I am able to see just 2-3 characters printed on the LCD. If I pause the execution, I can see it is waiting at the line, while((LPSPI1->SR & LPSPI_SR_TDF_MASK)>>LPSPI_SR_TDF_SHIFT==0); in the LPSPI1_transmit_16bits (uint16_t send) function.

Now if I again resume the execution, again 2-3 characters are printed on the LCD screen and again the same scenario repeats. Again if I pause and resume again 2-3 characters are printed. I have attached the program files for reference. Please let me know if I have to make any changes.

0 Kudos
Reply

2,075 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Apparently you dont fulfill timing required by SPI slave. Please consult SPI protocol requirement by SPI slave device.

0 Kudos
Reply

2,145 Views
RahulL
Contributor I

Hey David,

Thank you for your response. I will check this example. But, I am trying non SDK application. It would be great if you can help me with an example for non SDK application.

0 Kudos
Reply

2,161 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Hi, for instance example used both, master and slave.

lpspi_transfer_s32k148

davidtosenovjan_0-1617205465370.png

 

0 Kudos
Reply