This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to utilize DMA efficiently when retrieving data from SPI port

Other Parts Discussed in Thread: ADS1298, DM3730

Hi,

All genius:

In my project, DM3730 works as an SPI master in 8bit mode - the peer side is one sensor chip (TI ECG chip - ADS1298).

In my work system, DM3730 is running in wince 6.0.

The sensor chip would report captured data (27bytes) in 1k frequency (per 1ms) to DM3730 which is preceded by one "data ready" interrupt signal  - it's connected to one GPIO in DM3730. During he proecedure, data transfer is undertook by DMA channel which is connected and triggered with SPI channel RX register in hardware. All data (continous frames) would be put into one physcial memory block to be taken way by DSP.

In current source code, I create one high-priority kernel thread to receive data frame (27bytes). Below is basic structuer of main loop within the thread.

int 1FrameThread( )

{

    while(1)

    {

           wait_for_data_ready_event( );  //update destination buffer base address (+1frame) each time

          start_tx_rx_dma_in_spi_channel( );

          wait_for_dma_complete( );

         stop_tx_rx_dma_in_spi_channel( );

    }

Now I encountered with lots of problem, wish your guy's help.

1) In even frame reception (frame0, frame2,frame4...), "wait_for_dma_complete" will return quickly. In contrast, in odd frames, it always fails because of "timeout". But it's weird" that even in odd frame, when I dump memory content in dsp share memory, it's correct  (frame header is fixed-value).

     So my question is why it will fail? And if I don't care about timeout result ,just wait for  a fixed peroid and then stop dma channel , is data transfer stable and reasonable?

2) In current design, in each frame reception, I need to restart DMA channel (tx+rx) - even it's identical with the previous one and stop them. Is it possible to skip the actions (start+stop) - I mean, just start once (in first frame) and stop once (in las frame end) since RX DMA channel is triggered by spi rx register in hardware.

   If the method is achievable, I will spend lots of time and reduce thread loading hardly.

3) I have tried to make SPI channel working in RX only mode. With respect to data sheet, in this mode, one just need to send one SPI word (in my case, 1 byte) to tx register, then remain 26 bytes would be sent to sensor chip in same content. Of course, 27 bytes would be received by DMA automatically.

   I's apparent thread loading would be reduced more.

   But unfortunately, in my coding experience, I only observer one byte transaction (tx and rx) between dm3730 and sensor chip through SPI protocol analyser.

   I wish to know how can I make it working in rx only mode in right way.

4) In my case, one frame (27bytes) need to be received in onc CS cycle - I mean, pull down CS pin (active), and then accomplish 27 bytes transaction. then pull up CS. The procedure will need help of CS_FORCE feature of SPI channel.

    I found in wince SPI driver, if you call ioctrl( SPI_FORCE_CS), dma channel would be stopped and released.

    I wonder why - DMA transmission is not supported in this case?

   After I remove the action of abolish DMA channel, it seems that SPI TX/RX works well except abnormal phenomenan in section 1).

 

That's all ,

Wish your help

Thank you, all guys.

 

 

 

}