Hi,NXP team.
I’m using S32K3 as SPI slave.I have seen the demo,it seems to use loopback mode.
In demo code ,slave transfer API and master transfer API are implamented after SPI initialization.After that,the transfer will go on in SPI callback function.
I’d like to know when I should implamemt the first transfer API if another chip acts as master? I can't predict when the master will send data.
Best regards.
Rey
Solved! Go to Solution.
Hi @rey,
This is application-dependent, you could use another IO signal to notify the Slave device, for example.
But as the RM states, "Before the PCS input asserts, the transmit FIFO must be filled with transmit
data, or the transmit error flag sets." (Section 67.3.2 Slave mode, RM rev.3).
BR, Daniel
Hi rey,
Thank you for your thread! I've learnt a lot from it.
I'm using S32K3 as SPI slave too. And I want to make the S32K3 can receive SPI messages continuously as soon as possible, so I configured SPI5 as slave mode with DMA enabled.
But when I send amount data to the S32K3, it will get into the (LPSPI_IP_EVENT_FAULT = 1) error state.
This is my SPI slave callback function. Is my "SPI slave callback function" the same as yours?
Flowing is my SPI slave callback function.
····································································································
// @brief spi slave receive code
char spi5_recv[50] = {0};
const char spi5x_send[50] = {0};
void Spi5SlaveDmaCallback(uint8 Instance, Lpspi_Ip_EventType Event) {
if (Instance == 5) {
switch (Event) {
case LPSPI_IP_EVENT_END_TRANSFER:
Lpspi_Ip_AsyncTransmit(&Lpspi_Ip_DeviceAttributes_SpiExternalDevice_5_BOARD_InitPeripherals,
spi5x_send, spi5_recv, 32, Rt1176SpiAsyncRecvCallback);
break;
case LPSPI_IP_EVENT_FAULT://
rt_kprintf("e");
break;
default:
break;}}}
void StartSpi5SlaveDmaRecvData(void) {
Lpspi_Ip_AsyncTransmit(
&Lpspi_Ip_DeviceAttributes_SpiExternalDevice_5_BOARD_InitPeripherals,
spi5x_send, spi5_recv, 32, Rt1176SpiAsyncRecvCallback);
}
·····························································································
Best regards,
autolan22
Hi @danielmartynek,
Thanks for your repley,your suggestion is helpful. I prepare transmit buffer filled with dummy data at the beginning and wait for PCS assertion .Transmit buffer would been refreshed in callback function. It works well.
Another question , K3 software reset function "Power_Ip_CortexM_WarmReset" doesn't work. I also try CM7 standard function, it doesn't word either. Is there anything else that needs to be configured?
BR!
Rey
Hi Rey,
I'm glad it works,
Can you open a new thread for the Power_Ip ?
Thank you
Hi @rey,
This is application-dependent, you could use another IO signal to notify the Slave device, for example.
But as the RM states, "Before the PCS input asserts, the transmit FIFO must be filled with transmit
data, or the transmit error flag sets." (Section 67.3.2 Slave mode, RM rev.3).
BR, Daniel