cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB05KZ ADC Battery monitoring

Ruben_EMI
Associate II

I am using a STM32WB05KZ of a custom PDB, and I can not read a correct value of Vbattery.

I have programed the ACD (+DMA) usgin CubeMX.

Captura de pantalla 2026-03-13 100030.jpg

Captura de pantalla 2026-03-13 100106.jpg

  

 

I use DMA to read the analog inputs:

ADC_Conv_Cplt = 0;
HAL_ADC_Start_DMA(&hadc1, value, 3);
uint32_t start = HAL_GetTick();
while(ADC_Conv_Cplt==0){
  //timeout
  if ((HAL_GetTick() - start) > 3000){//wait 3 seconds
    break;
}
};

HAL_ADC_Stop_DMA(&hadc1);


According de manual, the formula for ADC converted data after calibration is the following: Code = Integer(4096/3.6 * VIN) [clamped at 4095]. The result of conversion from Vbat is 0x271, applying the formula I get 0,549V when the Vbat is 3V.

I also use 2 analog inputs in PB2 and PB5 and nome of them read correctly. In other proyects with stm32l105 and stm32wl55 the DMA works. I sure I am doing something wrong...

Can anybody help me?


Edited to apply proper source code formatting - please see How to insert source code for future reference.

10 REPLIES 10

I looked at it. I don't spot any issues. It may be an issue specific to the STM32WB05 which I'm not as familiar with.

If you feel a post has answered your question, please click "Accept as Solution".