Skip to content

Incorrect temperature and core voltage reading if analog power supply (Vdda) is different from 3.3V #6

@amalashanka

Description

@amalashanka

The problems comes from using a hard-coded macro VDDA_APPLI that is fixed to 3300mV in ADCCTRL module:

#define VDDA_APPLI (3300UL)

As a result, if a different MCU supply voltage is used (e.g., 3V), the ADCCTRL will silently produce incorrect readings, still assuming the Vdda is 3300mV.

Steps to reproduce:

  1. Use NUCLEO-WBA55 or NUCLEO-WBA65 board
  2. Use any CubeMX example that includes ADCCTRL module and modify it to periodically print out core temperature or core voltage
  3. Ensure it produces plausible results (e.g., temperature around 30 degrees Celsius, core voltage around 3300mV)
  4. Use STLINK-V3PWR or similar to feed Vdd line with 3V instead of 3.3V using JP2 header on the Nucleo board
  5. Observe incorrect readings

The suggestion is to move the definition of VDDA_APPLI from adc_ctrl.c into application configuration header (app_conf.h) as this is clearly an application-specific parameter.

Going a bit further with improvements, it would be nice to treat VDDA_APPLI as a function-like macro. With this the users who want or need to use the actual reference voltage reading will be able to define VDDA_APPLI in their app_conf.h to call their function to provide the reference voltage readings, while those who are ok with a hard-coded value are still ok to use it. For example:

#define CFG_GET_VDDA_APPLI()         my_get_reference_voltage_func()
vs
#define CFG_GET_VDDA_APPLI()         (3300U)

Identified instances of the issue:

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestneeds clarificationNeeds clarification or inputs from the userprojectsProjects-related (demos, applications, examples) issue or pull-request.

Projects

Status

Analyzed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions