Skip to main content
MFaiz.2
Associate
August 11, 2020
Question

STM32G030 ADC issue

  • August 11, 2020
  • 9 replies
  • 5091 views

Hello,

I am using STM32G030C8 microcontroller's several ADCs. Most of them are working okay but two of them (ADC1 IN15, PB11 and ADC1 IN16, PB12) are not showing correct ADC values.

In ADC IN15: When I use only this channel in the code then it shows 0 but when I read multiple channels it shows the value of the channel which is read before it.

In ADC IN16: The value is always very low regarding the actual voltage on that pin.

My VREF is 2.5V. I generated the code with CubeMX and using Keil IDE.

I have tested it in more than 1 hardware with same results. Also I have technically verified the voltage at the pin. The voltage at said pin is varied from 1.2V to 1.5V. Same type of input signals are applied to ADC channels 7,8,9,10,11 and reading values without any issues.

Also uploading the project for reference

This topic has been closed for replies.

9 replies

waclawek.jan
Super User
August 11, 2020

Sounds like high input signal impedance/inadequate sampling time.

What's the input signal source?

JW

MFaiz.2
MFaiz.2Author
Associate
August 11, 2020

Input is driven by opamp. I am sure this is not an input issue because 5 other channels are connected with same type of input but they are showing correct readings.

TDK
August 11, 2020

Check your CHSELRMOD bit. If it's 1, only channels 0-14 may be selected for regular conversion.

0693W000003OwMpQAK.png

If it's 0, you can select any channel.

0693W000003OwPTQA0.png

"If you feel a post has answered your question, please click ""Accept as Solution""."
MFaiz.2
MFaiz.2Author
Associate
August 11, 2020

CHSELRMOD_bit is 0 as shown in screenshot

 As you can see, channel_15 value is exactly same as channel_3 value because it is read before channel_15.

If I disable all other channels and only enable channel_15 then it will read exact 0.

Interesting point is all HAL functions return OK status.

TDK
August 11, 2020

Set it up in CubeMX to see the correct code to convert channel 15+.

"If you feel a post has answered your question, please click ""Accept as Solution""."
waclawek.jan
Super User
August 11, 2020

Humm, ST gets really inventive in the ADCs... no two alike... TDK, don't you happen to know, this "feature", is it present in any other STM32 family too?

JW

TDK
August 11, 2020
It’s the first time I’m seeing it. It is certainly not in the families I’ve used a lot in the past. F4, H7
I first tried to set it up in CubeMX and it reported an error, so I investigated the reference manual.
"If you feel a post has answered your question, please click ""Accept as Solution""."
TDK
August 11, 2020

> I have used CubeMX, though it didn't give me any error. Original project files are attached with question

Your project only converts a single channel, channel 3. The error is not in the CubeMX generated code, it's in the user code you added.

Channels 1, 15 and 16 are set up as inputs, but they're not actually part of the conversion in your project.

0693W000003OxMBQA0.png

"If you feel a post has answered your question, please click ""Accept as Solution""."
MFaiz.2
MFaiz.2Author
Associate
August 12, 2020

I am changing the channels in my main code in while(1) loop

TDK
August 12, 2020

You're going to have to dig into the HAL code to ensure it's setting the right register values.

"If you feel a post has answered your question, please click ""Accept as Solution""."
waclawek.jan
Super User
August 12, 2020

Read out and check/post the relevant registers content after switch.

JW

Nichal Lee
Visitor II
March 22, 2021

Was this issue solved?

I have the same issue with STM32G030K6.

My situation is :

While the ADC input signals using Voltage divider resistance, it works correct !

But if the input signals using opamp, it goes to zero ! (ADC_IN0-PA0/ ADC_IN1-PA1)

I've checked the HAL settings, all the same.

And double check by multi-meters, the true voltage is zero too while connecting to opamp!

These pins are really weird.

But using the same way on G431 is totally OK!

Is there any user guide to solve this issue?

waclawek.jan
Super User
March 22, 2021

Please start a new thread, stating the problem in details (what opamp do you use, how is it connected/set up, where do you measure, etc.), perhaps linking to this thread if it's relevant.

JW