Skip to content

[F1] How do I debug ADC / analogRead() not working? #552

Closed
@benwaffle

Description

@benwaffle

Describe the bug
analogRead() is returning incorrect / garbage values. A multimeter between PA2 and GND shows the correct value.

To Reproduce

#include <Arduino.h>

void setup() {
    Serial.begin(923076);
    pinMode(PA2, INPUT_ANALOG);
    analogReadResolution(12);
}

void loop() {
    Serial.print(analogRead(PA2) / 4096.0 * 3.3);
    Serial.println(" V");
    delay(200);
}

Steps to reproduce the behavior:

  1. Run code
  2. Connect an analog input to PA2
  3. See incorrect value

Expected behavior
Expected that code reads correct voltage as measured by multimeter.

Desktop:

  • OS: Mac
  • STM32 core version: 1.6.1
  • Upload method: STLink

Board:

  • Name: STM32F103C8T6 (Bluepill)

Metadata

Metadata

Assignees

No one assigned

    Labels

    question ❓Usually converted as a discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions