Skip to content

STM32G071/081 Analog Pin Mapping Errors #736

Closed
@steenerson

Description

@steenerson

Describe the bug
Several ADC pins report incorrect values on STM32G0x1 series boards, I have tried separate hardware with G071RBT6 and G081RBT6 and both exhibit similar issues. On my Nucleo-G071RB board, 3 are not working correctly:

PB11/A4 - always returns 0
PB12/A5 - sketches performing analogRead of PB12 seem to be reading physical pin PA0 instead of PB12. Continuity tests with multimeter match the schematic - PB12 is physically connected to socket A5 and they are not shorted to PA0. With the board completely unplugged from power/peripherals I measure 10-15Mohm between PA0 and PB12, leading me to believe it is a software issue and not hardware.
PB0/D10 - similarly, sketches reading PB0 seem to be reading physical pin PB10.

On a board I made with a STM32G081RBT6 and a custom variant, I'm attempting to use all 16 analog pins and at least 4 are reading incorrectly - PB11, PB12, PC4 and PC5 readings don’t match the measured voltage on the pin. The variant I made has all of the analog pins in variant.h and variant.cpp in the same order as in the PinMap_ADC section of PeripheralPins.c, which seems to make PB0 work correctly compared to the Nucleo board, but PB11/PB12/PC4/PC5 haven’t worked in any order I’ve tried.

To Reproduce

void setup() {
  analogReadResolution(12);
  Serial.begin(115200);
  pinMode(PA0, INPUT);
  pinMode(PA1, INPUT);
  pinMode(PA4, INPUT);
  pinMode(PA6, INPUT);
  pinMode(PA7, INPUT);
  pinMode(PB0, INPUT);
  pinMode(PB1, INPUT);
  pinMode(PB2, INPUT);
  pinMode(PB10, INPUT);
  pinMode(PB11, INPUT);
  pinMode(PB12, INPUT);
}

void loop() {
  Serial.print("PA0/A0 volts = ");
  Serial.println(analogRead(PA0) / 1241.2);
  Serial.print("PA1/A1 volts = ");
  Serial.println(analogRead(PA1) / 1241.2);
  Serial.print("PA4/A2 volts = ");
  Serial.println(analogRead(PA4) / 1241.2);
  Serial.print("PA6/D12 volts = ");
  Serial.println(analogRead(PA6) / 1241.2);
  Serial.print("PA7/D11 volts = ");
  Serial.println(analogRead(PA7) / 1241.2);
  Serial.print("PB0/D10 volts = ");
  Serial.println(analogRead(PB0) / 1241.2);
  Serial.print("PB1/A3 volts = ");
  Serial.println(analogRead(PB1) / 1241.2);
  Serial.print("PB2/CN10_22 volts = ");
  Serial.println(analogRead(PB2) / 1241.2);
  Serial.print("PB10/CN10_28 volts = ");
  Serial.println(analogRead(PB10) / 1241.2);
  Serial.print("PB11/A4 volts = ");
  Serial.println(analogRead(PB11) / 1241.2);
  Serial.print("PB12/A5 volts = ");
  Serial.println(analogRead(PB12) / 1241.2);
  Serial.println();
  delay(1000);
}

Steps to reproduce the behavior:

  1. Run above code
  2. Open 115200 baud serial monitor
  3. Use short jumper wire to induce 3.3V on analog pins

Expected behavior
Plugging 3.3V into PB0, PB11 and PB12 will cause them to read 3.3V (4095), but instead they read .5-1v with high variability, as if floating.

Plugging 3.3V into PA0 and PB10 will only cause those pins to read 3.3V, but instead each causes 2 pins to read 3.3V.

Screenshots

Desktop (please complete the following information):

  • OS: Windows
  • Arduino IDE version: 1.8.10
  • STM32 core version: 1.7.0
  • Tools menu settings if not the default:
  • Upload method: STLink (SWD)

Board (please complete the following information):

  • Name: Nucleo G071RB
  • Hardware Revision: MB1360-G071RB-C01
  • Extra hardware used if any: jumper wire

Additional context

Metadata

Metadata

Assignees

Labels

bug 🐛Something isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions