2012-06-27 04:21 PM
using gcc 4.5.2, st-util 4242, stm32f4discovery, ADC3_DMA peripheral examples from STM32F4-Discovery_FW_V1.1.0, ld file from TrueStudio, startup file from CMSIS.
When I run the program in the debugger the ADC value does not change. If I connect PC2 to VDD then I get ADCConvertedValue=4089. It stays the same until I unplug the USB and start over, then it is 4092. If I connect PC2 to GND then ADCConvertedValue=0. In any case it does not change during the power cycle. (I don't know if this matters, but while I am stepping through the code, it never enters an interrupt routine, it just stays in the main while loop copying the data from ADCValue to ADCVoltage.)Please let me know if you have any ideas on how to get the ADCValues to update. Thanks. #adc-stm32-discovery2012-06-27 07:44 PM
Is Continuous Conversion Mode disabled ?
If that doesn't help, post your code. Cheers, Hal2012-06-27 11:46 PM
The values sound reasonable.
How do you trigger the ADC, and when ? If you do not have continuous mode configured, you need to trigger the ADC regularly..(I don't know if this matters, but while I am stepping through the code, it never enters an interrupt routine, it just stays in the main while loop copying the data from ADCValue to ADCVoltage.)I guess you set a breakpoint into the interrupt code. The debugger does not just follow interrupts. Is your ADC interrupt correctly initialized, and enabled ? You should be able to check the ADC interrupt status flag anytime in single-step mode.
2012-06-28 11:24 AM
It is example code which is available to anyone, for example from here:
129 ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; 130 ADC_InitStructure.ADC_ScanConvMode = DISABLE; 131 ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; 132 ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; 133 ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; 134 ADC_InitStructure.ADC_NbrOfConversion = 1; 135 ADC_Init(ADC3, &ADC_InitStructure); the makefile which I use is attached. ________________ Attachments : Makefile.ADC3_DMA : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006qbAJ&d=%2Fa%2F0X0000000bpE%2F1BwLCxvd.MgdqUx3.okC2bO0fgCaP0UteB73XzUYa6I&asPdf=false2012-06-28 11:47 AM
I am not triggering the ADC explicitly, I haven't looked into any of the interrupt flags.
I added this line:ADC_InitStructure.ADC_ExternalTrigConv = 0;and it worked once but then it stopped working again. It must be something to do with how I am booting the device. I have one window which I type st-util 4242 usb and another window withgdb:file ADC3_DMA.elftarget extended localhost:4242loadbreak maincont2012-06-28 04:32 PM
The ADC works if I reset the device with the black reset button.
(in the debugger info reg shows that everything is zeroed.)So the problem is solved. I am a little mystified over why there is different behavior when you 1) reset with the reset button and when you unplug/plug the usb or 2) when you reset in the debugger for that matter. Thanks for the help.2012-06-29 12:21 AM
It might have been an issue with the debugger.
The example you compiled does not use interrupts. It configures the ADC in continuous mode, with SW trigger, and then configures the DMA to move the result continuously from the ADC->DR into your variable. It starts the conversion once before entering an endless loop, where it only reads the result. This way, you are not bothered with interrupts, the ADC/DMA chain permanently delivers the new conversion result, without further notification. At least, it is not the example I would have started with...