cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong values on ADC without debugger but OK with debugger

srikrishnan
Associate II
Posted on March 31, 2017 at 23:59

I am using ADC1 in scan mode. When I run my code normally through the debugger, it works just fine. However, when I remove the debugger and directly run it, I am seeing extremely low voltages. What could possibly be the reason for this? Has anyone else seen this? I have compiler optimization turned off to ensure there isnt much of a difference due to compiler optimization. It does not happen on all boards and only on 10%. I have also tried slowing the ADC sample times to as low as possible(239.5 cycles). I normally run them on 1.5 on all boards and I am good (with and without debugger). I have also reviewed the board under a microscope and there is no hardware issue. FWIW, I am supposed to read 24V and I am reading 2.36V.

18 REPLIES 18
Posted on April 01, 2017 at 00:37

24V? Assuming that is a typo

Is the debugger introducing power to the board?

Check the VREF and VDDA voltages?

Assuming an STM32F1 type product, helps to be specific.

Check the the ADC using the VREFINT (Internal reference, 1.25V?)

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
Posted on April 01, 2017 at 07:59

What STM32 part number is it? When using debugger, how? Just run, no breakpoint and no live watch variable window?

Is VDDa / VDDa connected to supply voltage? analog input should remain within 0 V and VDDa voltage for the ADC.

antonius
Senior
Posted on April 01, 2017 at 08:15

I reckon your debbuger is feeding a power supply to your MCU as well, that's why it's dropped when you plug it out

srikrishnan
Associate II
Posted on April 02, 2017 at 03:58

Its an XL density - STM32F103Z part. I suspect the debugger is introducing power to the board. But it seems to fix the problem. I am wondering why the behavior ceases.

Posted on April 02, 2017 at 03:55

Yes, sorry its a scaled value. The raw value is 0-3V. So analog of 24V should be read as 1.699V. But I am seeing 0.02V.

Posted on April 02, 2017 at 04:01

It doesnt matter, if I start the debugger, it works. If I remove it and run binary, it does not work.

Posted on April 02, 2017 at 13:14

Run with the debuuger, then unplug it to see what happen.

Posted on April 02, 2017 at 15:39

Its an XL density - STM32F103Z part. I suspect the debugger is introducing power to the board. But it seems to fix the problem. I am wondering why the behavior ceases.

Posted on April 02, 2017 at 15:47

Not familiar with the board design.

I'd make sure that the BOOT0 pin is pulled low for normal operation.

Make sure all the clocks you need are enabled, the debugger may configure some settings to suit its needs, so might not entirely reflect normal reset conditions.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..