cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle left-aligned ADC data?

callsignhermit
Associate II

The STM32Cube API provides several helper macros for working with ADC data, including:

  • __HAL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)
  • __HAL_ADC_CONVERT_DATA_RESOLUTION(__DATA__, __ADC_RESOLUTION_CURRENT__, __ADC_RESOLUTION_TARGET__)
  • __HAL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__, __ADC_DATA__, __ADC_RESOLUTION__)
  • __HAL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__, __ADC_RESOLUTION__)

These accept ADC resolution as input, so I guess I don’t have to convert data to a specific resolution (in the case of the third and the fourth macros)

I’m curious if they also account for ADC data alignment, or should the data from the ADC DR be normalized and right-aligned before given to them? (Except perhaps for the first one, since the number of ADC bins is independent of alignment.)

0 REPLIES 0