AnsweredAssumed Answered

SPI xfer using DMA

Question asked by manoj.mohith on Nov 16, 2011
Latest reply on Nov 16, 2011 by manoj.mohith
Hi,
I have my STM32F103RB connected to an ADC via SPI1.

I read my ADC in two modes, in single shot mode I do SPI transfer in polling mode and all works well.

In continuous mode I need to read data from ADC every 2mS which is achived by sending n bytes (0x00) to the ADC and it sends back the last converted sample. Here I am trying to use two DMA channels, one for sending the n 0x00 bytes and another one to read received bytes and place it in a buffer.

I have configured my DMA channel for receive (DMA1_Channel2) for circular operation and DMA channel for transmit in normal mode with M2M disabled in both cases.

The ADC gives an interrupt through one of the EXTI lines where in the ISR I disable the DMA channel for TX, re-load the count and enable it back. All I get is a transfer error interrupt for this channel! At this time my CNDTR reads the same value I had loaded in the EXTI ISR, meaning nothing was sent in the SPI TX line which is confirmed by probing the SPI_CLK line with an oscilloscope.

Q1. Is it OK to have the same SPI configured with DMA on both TXE and RXNE
Q2. If yes, how to start SPI TX?

Please help

Outcomes