AnsweredAssumed Answered

toggle GPIO with DMA on ADC conversion finish (STM32F407)

Question asked by fachet.benjamin on Oct 22, 2013
Latest reply on Oct 28, 2013 by fachet.benjamin
Hello,

is it possible to configure a DMA job to toggle an GPIO when the ADC conversion finishes?
I'am using Timer8 to Trigger ADC1 conversion and DMA2 Stream0 Channel0 to copy the conversion result (DR-Register) to internal RAM.

Now, for testing purpose only, i want to toggle Pin C5 at the end of the ADC conversion using this DMA config:

st_DMA_ADCtoRAM.DMA_PeripheralBaseAddr = (uint32_t)GPIOC_BASE + 0x18; // 0x18 = BSRR-Register Offset  
st_DMA_ADCtoRAM.DMA_Memory0BaseAddr =    (uint32_t)au32_TestOut;                                       
st_DMA_ADCtoRAM.DMA_DIR = DMA_DIR_MemoryToPeripheral;                                                 
st_DMA_ADCtoRAM.DMA_BufferSize = 2;


with:
#define TESTHIGH (1<< 5    )
#define TESTLOW  (1<<(5+16))
 
au32_TestOut[0] = TESTHIGH;
au32_TestOut[1] = TESTLOW;

but this doesn't work. DMA2 Stream4 Channel0 deosn't work either:
DMA_Cmd(DMA2_Stream4, DISABLE);
DMA_DeInit(DMA2_Stream4);
st_TESTtoGPIO_Config.DMA_Channel = DMA_Channel_0;
st_TESTtoGPIO_Config.DMA_PeripheralBaseAddr = (uint32_t)GPIOC_BASE + 0x18; // 0x18 = BSRR-Register Offset
st_TESTtoGPIO_Config.DMA_Memory0BaseAddr =    (uint32_t)au32_TestOut;
st_TESTtoGPIO_Config.DMA_DIR = DMA_DIR_MemoryToPeripheral;
st_TESTtoGPIO_Config.DMA_BufferSize = 2;
st_TESTtoGPIO_Config.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
st_TESTtoGPIO_Config.DMA_MemoryInc = DMA_MemoryInc_Enable;
st_TESTtoGPIO_Config.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; 
st_TESTtoGPIO_Config.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
st_TESTtoGPIO_Config.DMA_Mode = DMA_Mode_Circular;
st_TESTtoGPIO_Config.DMA_Priority = DMA_Priority_Low;
st_TESTtoGPIO_Config.DMA_FIFOMode = DMA_FIFOMode_Disable;
st_TESTtoGPIO_Config.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
st_TESTtoGPIO_Config.DMA_MemoryBurst = DMA_MemoryBurst_Single;
st_TESTtoGPIO_Config.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA2_Stream4, &st_TESTtoGPIO_Config);
DMA_Cmd(DMA2_Stream4, ENABLE);

Outcomes