SPI Lpspi_Ip_AsyncTransmit not work

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

SPI Lpspi_Ip_AsyncTransmit not work

1,195 Views
liqingfa
Contributor I

my spi set as follows:

/* Initialize each Spi hardware units using*/
Lpspi_Ip_Init(&Lpspi_Ip_PhyUnitConfig_SpiPhyUnit_0_Instance_0_VS_0);
 
/* Update Framesize */
Lpspi_Ip_UpdateFrameSize(&MASTER_EXTERNAL_DEVICE, 8U);
 
/* Update Transfered Bit order */
Lpspi_Ip_UpdateLsb(&MASTER_EXTERNAL_DEVICE, FALSE);
 
/* Update Transfer Mode */
Lpspi_Ip_UpdateTransferMode(MASTER_EXTERNAL_DEVICE.Instance, LPSPI_IP_INTERRUPT);
 
/* Master starts transfer, synchronous method is used */
Lpspi_Ip_SyncTransmit(&MASTER_EXTERNAL_DEVICE, TxMasterBuffer, RxMasterBuffer, NUMBER_OF_BYTES, TIMEOUT);

it work for SyncTransmit,but i want change to AsyncTransmit,i just change function "Lpspi_Ip_SyncTransmit(&MASTER_EXTERNAL_DEVICE, TxMasterBuffer, RxMasterBuffer, NUMBER_OF_BYTES, TIMEOUT);" to "Lpspi_Ip_AsyncTransmit(&MASTER_EXTERNAL_DEVICE, TxMasterBuffer, RxMasterBuffer, NUMBER_OF_BYTES, (Lpspi_Ip_CallbackType)spi_callback);" . i think it should work, but it not work. what can i do ?

0 Kudos
Reply
4 Replies

1,172 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

what does not work in fact?
The only difference between functions is a Sync one does not finish until transfer is finished or timeout happens, while Async one starts transfer and leave function. User should check for end of transfer either using a callback or calling GetStatus function, I think.
Also do you have LPSPI interrupt installed/initialized?

BR, Petr 

0 Kudos
Reply

1,056 Views
liqingfa
Contributor I

Hi PetrS,do you mean the AsyncTransmit must use interrupt "Lpspi_Ip_LPSPI_0_IrqRxDmaHandler" to check the LPSPI_IP_IDLE status? 

0 Kudos
Reply

1,028 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

as I wrote, for async function you need to wait for end of transfer. Function just prepare transmission/reception and leave. So either you will check module status using Lpspi_Ip_GetStatus, it returns IDLE after transfer is finished. Or if you define callback within Async function, this callback will be called with event LPSPI_IP_EVENT_END_TRANSFER after transfer is done.

BR, Petr 

0 Kudos
Reply

1,077 Views
liqingfa
Contributor I

Hi,PetrS,I means use function “Lpspi_Ip_SyncTransmit(&MASTER_EXTERNAL_DEVICE, TxMasterBuffer, RxMasterBuffer, NUMBER_OF_BYTES, TIMEOUT);” I can get the message with DMA, but replace the function "Lpspi_Ip_AsyncTransmit(&MASTER_EXTERNAL_DEVICE, TxMasterBuffer, RxMasterBuffer, NUMBER_OF_BYTES, (Lpspi_Ip_CallbackType)spi_callback); ". I can not get the message with DMA. I have LPSPI interrupt installed/initialized, such as"IntCtrl_Ip_InstallHandler(LPSPI0_IRQn, Lpspi_Ip_LPSPI_0_IRQHandler, NULL_PTR);
IntCtrl_Ip_EnableIrq(LPSPI0_IRQn);".

0 Kudos
Reply