2014-02-21 01:14 AM
Hi, please I need a little help.
I'm using a STM32L151RCT6A in a project. We need to distiguish the hardware version of boards, so to use a single pin, we read the voltage on a partitor made of two resistor.It is connected to pin PC5, corresponding to analog input 15.Actually, lower resistor is 1,3k? and upper is 10k?. On 12 bits, I expect to read 471.Now, the strange behaviour: the value read is greater, approx. 1300 to 1500 instead.I tried to add delays, or some tests to control if value decreased because any discharge, but not, it stays at those levels.But if I set a breakpoint after conversion, and then I retry to convert, value is correct!I tried also to read with same code another ADC channel (nr. 4) where battery is connected, and it reads correctly.Someone has an idea? #show-code2014-02-21 02:29 AM
Someone has an idea?
What's the sample time?2014-02-21 02:47 AM
What happens if you discard the first result, and use the second (or third one) ?
BTW, unless you are tight on GPIOs, using digital inputs for HW revision detection is more common. Just pull 3 or 4 inputs up (down), and insert jumpers (0R resistors) in a binary coded manner. Beside of never giving fuzzy results (like ADC readings), this allows for an easy visual recognition of HW revision, even by laymen.2014-02-21 03:12 AM
I set ADC_SampleTime_384Cycles, it works on channel 4.
What I find incredible it's if I execute code in run mode, the result is incorrect, but if I do it in step or setting SWSTART manually, then value is ok.Thanks2014-02-21 03:18 AM
Dear fm, I used this system on other boards already with success.
On this project I haven't any other pin free to put digital jumpers.I made a loop to check if values were differents each other to avoid glitches.They are all about three times bigger!Thanks2014-02-21 03:27 AM
Hi
''I expect to read 471. Now, the strange behaviour: the value read is greater, approx. 1300 to 1500 instead.'' ''But if I set a breakpoint after conversion, and then I retry to convert, value is correct!'' If the test is being done in the boot/startup - it may be done before the supply rail has settled. The STM32 can start on a supply voltage as low as 1.8V I am not saying this is the problem - just a thought.2014-02-21 03:31 AM
No, supply is stabilized.
Then, I'm testing, it's switched on from many hours.2014-02-21 03:36 AM
On this project I haven't any other pin free to put digital jumpers.
It was a mere suggestion, under the assumption you have free pins.I made a loop to check if values were differents each other to avoid glitches.
They are all about three times bigger!
What is the reading if you connect this ADC input to 0V and 3.3V ? Could you try to connect another ADC input to the same network, and compare both ? Besides of possible ADC configuration problems, you do any scaling ?