LPC55S69 Continuous Data reception using SPI with DMA

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

LPC55S69 Continuous Data reception using SPI with DMA

2,907 Views
Akashlp
Contributor I

I wanted to read the sensor data continuously using SPI DMA mode. But with following code able to read the data only beginning and later will not be reading continuously. Please help to solve to read data continuously.

Following code is implement using SDK examples

/* DMA init */
DMA_Init(EXAMPLE_DMA);
/* Configure the DMA channel,priority and handle. */
DMA_EnableChannel(EXAMPLE_DMA, EXAMPLE_SPI_MASTER_TX_CHANNEL);
DMA_EnableChannel(EXAMPLE_DMA, EXAMPLE_SPI_MASTER_RX_CHANNEL);
DMA_SetChannelPriority(EXAMPLE_DMA, EXAMPLE_SPI_MASTER_TX_CHANNEL, kDMA_ChannelPriority0);
DMA_SetChannelPriority(EXAMPLE_DMA, EXAMPLE_SPI_MASTER_RX_CHANNEL, kDMA_ChannelPriority0);
DMA_CreateHandle(&masterTxHandle, EXAMPLE_DMA, EXAMPLE_SPI_MASTER_TX_CHANNEL);
DMA_CreateHandle(&masterRxHandle, EXAMPLE_DMA, EXAMPLE_SPI_MASTER_RX_CHANNEL);

 

spi_transfer_t masterXfer;

/* Set up handle for spi master */
SPI_MasterTransferCreateHandleDMA(EXAMPLE_SPI_MASTER, &masterHandle, SPI_MasterUserCallback, NULL, &masterTxHandle,
&masterRxHandle);

/* Start master transfer */
masterXfer.txData = (uint8_t *)&masterTxData;
masterXfer.rxData = (uint8_t *)&masterRxData;
masterXfer.dataSize = TRANSFER_SIZE * sizeof(masterTxData[0]);
masterXfer.configFlags = kSPI_FrameAssert;

if (kStatus_Success != SPI_MasterTransferDMA(EXAMPLE_SPI_MASTER, &masterHandle, &masterXfer))
{
PRINTF("There is an error when start SPI_MasterTransferDMA \r\n ");
}

Labels (1)
0 Kudos
Reply
3 Replies

2,853 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi @Akashlp 

I hope that you are doing excellent!

Could you describe further the issue? Let me explain.

The spi_dma_b2b_transfer_master SDK example , has the following   output , when testing with another LPC55 board :

diego_charles_0-1633473993422.png

Where 64 bytes are transferred  (using  masterXfer.dataSize = TRANSFER_SIZE * sizeof(masterTxData[0]) )

As far I understand, your goal is  to initiate transfers with your sensor using  DMA correct? Maybe with a variable transfer length.

Is the second transfer interrupted  or halted? Or your sensor is not responding anything , so the received data is 0xFF or 0x00?

Thank you 

Diego

0 Kudos
Reply

2,839 Views
Akashlp
Contributor I

HI @diego_charles 

My goals is to receive the sensor data continuously and read on SPI DMA buffer. The length of data sent by sensor is 24 bytes to 30 bytes.

Even need to send some configuration setting data to sensor from SPI DMA.

I am able to read only 64 bytes of data on SPI buffer and later buffer is not updating.

0 Kudos
Reply

2,807 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi @Akashlp 

Thank you for your reply and for your patience. 

The other day, I replied with feedback on your internal ticket , with the same inquiry. Let me attach my reply , with several corrections , here. 

The SPI DMA  examples are coded to perform a single transfer between two boards. If you would like to perform multiple DMA transfers you will need to do some minor modifications on the examples.

If possible , I recommend you to test with two boards, your adaptation of the SPI DMA examples, this just to verify that your master code works as expected. Then perform communication with your SPI device.

As I did some tests with the LSPI DMA examples, I am attaching my code, just for reference.

Do not hesitate to let me know if you are still facing problems

Best regards, 

Diego.

 

 

 

0 Kudos
Reply