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.
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
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.
Apparently you dont fulfill timing required by SPI slave. Please consult SPI protocol requirement by SPI slave device.
Hi, for instance example used both, master and slave.
lpspi_transfer_s32k148