cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030F4P6 ADC with DMA strange values after some time

LukaszL
Associate II

Hello,

I have problem using ADC with DMA (I obtained the same problem using Interrupts). I have stable VDDA=3.3 V from LF33. On ADC channel 9 (PB1) I have voltage from 0 to 3.3V from potentiometer. When I set for example 0.35 V(ADC value about 400) and I leave whole circuit after some time (few minutes) MCU reach statement that ADC value is lower than 250 (about 0,2V), but voltage is still 0,35V. Could you help me? Maybe my code is wrong, because I'm beginner with STM32.

In attachemnt is my code. (low_level=250, high_level=650).

Thanks in advance for your replies.

4 REPLIES 4
LukaszL
Associate II

Hi,

I rearrange the code to simply use polling method, and problem still exist. When I set by potentiometer value 423 (1A7h) after some time I reach statement that value is lover or equal 250. Using breakpoint I know that the value read from ADC in this case is 160 (A0h). I have done few similar experiments and obtain values as follows:

should be:

423(1A7h) 327(147h) 355(163h)

after some time it is (the statement is reached):

160(A0h) 69(45h) 91(5Bh)

It looks like sometimes using HAL_ADC_GetValue() one bit in older byte is missing. Do you have such problem? Any idea how to resolve that issue?

asbjorn.heid
Associate III

I'm no expert so this is a stab in the dark.

You also do a lot in various interrupt handlers, like SYSTICK and GPIO EXTI. Erasing flash is a slow process, definitely not something that should be done in an interrupt handler.

I'd start by commenting out the code in those interrupt handlers, and also try to use async ADC clock just to check. Basically scale the code back to just doing the ADC conversions. If it works then, bring more of the code back in until you find the piece of code that leads to the issue.

LukaszL
Associate II

I have checked voltage on PB1 pin using oscilloscope and I saw randomly occurring negative pulses of amplitude about 100-200 mV. Those pulses were caused by bad layout of dc/dc converter (MC34063) I add few filtering ceramic capacitors around MC34063 and negative pulses are gone. Now my circuit is working as it should. 

Thank you very much for your advices.

Excellent, thanks for the follow-up. Something to keep in mind when I spin my own boards.