2026-03-13 2:11 AM - last edited on 2026-03-13 2:52 AM by Andrew Neil
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.
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.
2026-04-03 9:02 PM
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.