Sterling
Sterling
DIIDevHeads IoT Integration Server
Created by Sterling on 8/13/2024 in #firmware-and-baremetal
Why isn't my ADC with DMA setup updating the variable correctly on the STM32F407ZGT6?
I'm attempting to run through two ADC channels sequentially on my STM32F407ZGT6 using DMA to capture values from two independent potentiometers, one on each channel. The program doesn't crash, but the variable sensor_val isn't being updated as I would desire. I'm making use of the DMA2_Stream0 with Channel 0 for ADC1, and my ADC1 is configured to read from PB1 (channel 9) and PA1 (channel 1). I followed a tutorial closely but avoided triggering the ADC with a timer for now. I've also referenced an example related to this issue. However, my ADC callback isn't being invoked. Based on my understanding, the expected sequence should be: ADC1->SR EOC --> ADC->CR1 EOCIE --> DMA2_Stream0_IRQHandler() --> dma_ADC_callback() Should I include a periodic call to read through the ADC in order to resolve this? All the ADC/DMA functions are in separate .c/.h files. I've tried declaring sensor_val as both a global and extern variable within the adc.c file, but the result remains the same. Below is a simplified version of my code:
7 replies