S32K344 SPI slave mode

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

S32K344 SPI slave mode

跳至解决方案
1,946 次查看
rey
Contributor II

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

1 解答
1,931 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

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

 

在原帖中查看解决方案

0 项奖励
回复
4 回复数
1,640 次查看
autolan22
Contributor III

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

0 项奖励
回复
1,889 次查看
rey
Contributor II

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                                   

0 项奖励
回复
1,888 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Rey,

I'm glad it works,

Can you open a new thread for the Power_Ip ?

 

Thank you

 

0 项奖励
回复
1,932 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

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

 

0 项奖励
回复