2013-01-04 12:41 PM
Hi!
I am using STM32F0DISCOVERY kit and so far tried to run one of the peripheral examples called ADC_DMA. Short example description: ''The ADC1 is configured to convert continuously Voltage reference and Temperature sensor. Each time an end of conversion occurs the DMA transfers, in circular mode, the converted data from ADC1 DR register to the RegularConvData_Tab[] table.'' The temperature sensor is connected to channel ADC_IN16 and the internal voltage reference VREFINT is connected to channel ADC1_IN17. The order in which the channels are scanned is configured as follows: ADC_InitStructure.ADC_ScanDirection = ADC_ScanDirection_Backward; so (as I read from the documentation) the channels are scanned from Channel 18 to Channel 0, which means that VREFINT is converted first, and then temperature. This, in my opinion, should result in the first converted data (VREFINT) going to RegularConvData_Tab[0], and the second converted data (temperature) to RegularConvData_Tab[1]. However, the example code is written like this (note the indexes [0] and [1]): /* Convert temperature sensor voltage value in mv */ TempSensVoltmv = (uint32_t)((RegularConvData_Tab[0]* 3300) / 0xFFF); /* Convert Vref voltage value in mv */ VrefIntVoltmv = (uint32_t)((RegularConvData_Tab[1]* 3300) / 0xFFF); In fact, after running the program on board, I can see the temperature in RegularConvData_Tab[0] and VREFINT in RegularConvData_Tab[1]. Where's the mistake in my thinking? By the way: since the board has a VDD=VDDA=3V, I guess in the above equations there should be ''*3000'' instead of ''*3300''? I checked measuring voltage on some analog input (channel ADC_IN1) and multiplying by 3000 gave me pretty similar value to what the multimeter showed. Regards, Tomek2013-01-04 04:15 PM
A quick answer to your ''By the way'' - the example was written for an evaluation board which used 3.3V.
The F0 ADC is different from other processes I am familiar with. Perhaps after a bit of research I can help with an answer to the sequence problem. Cheers, Hal2013-01-05 09:10 AM
The example converted 4 channels, including VBAT, so it appears you are running a modified example. Post your code so we can review it.
Cheers, Hal2013-01-05 10:23 AM
My original code, without any change, looks like in the attached file. All peripheral examples that I got are taken from stm32f0discovery_fw.zip (to tell the truth, I don't remember where I got it from), which after decompressing is named as STM32F0-Discovery_FW_V1.0.0. Do you have some other (newer?) version? Where can I find it? Your information about some other board with VDD=3.3V shows that I have some obsolete code...
Thanks for dealing with my problem! Tomek ________________ Attachments : main.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I04y&d=%2Fa%2F0X0000000bTA%2FwbrTq2sCJ1_QQob8Y5PkRvtPHugn5stM.10VLgJR61Q&asPdf=false2013-01-05 04:24 PM
See esraf's 1/2/2013 post in the STM32 forum. His scan sequence is correct, but off by one position. If the last poster's comment in esraf's post is correct, that would explain your results. Add an external channel you can set to ground or Vref to verify sequence. I don't have an F0 to check this out.
ST doesn't include Discovery examples in the Standard Peripheral Library. That is one of the reasons the Discovery boards are inexpensive. Cheers, Hal2013-01-10 03:18 PM
Sorry for not responding so long. Thanks for indicating me the other post - that was it! Reading the ADC calibration factor indeed made everything shift by one position, I came up with a solution now.
Regards, Tomek