2025-11-10 8:43 AM
I can't find anything in CubeMX or HAL documentation or STM32G4xx_hal_adc.h or STM32G4xx_hal_adc_ex.h about how to enable Bulb Sampling Mode. How do I enable Bulb sampling mode using CubeMX and HAL?
Solved! Go to Solution.
2025-11-10 10:16 AM
Bulb Sampling Mode on STM32G4 ADCs isn’t directly exposed through CubeMX or HAL functions, so you’ll need to manipulate the registers directly. Key points:
Mode Activation – Set the BULB bit in ADCx->CFGR2 (check the reference manual for exact bit position).
Compatibility – Only works in discontinuous mode; not compatible with continuous conversion or injected channels.
Sampling Time – Bulb mode takes effect from the second conversion onward, and the first conversion uses the programmed sampling time. Maximum sampling time is limited—check the datasheet.
SMPTRIG – Make sure the SMPTRIG bit is not set when using Bulb mode.
DMA – For high-speed applications, pair with DMA to capture conversions efficiently.
In practice, you configure the ADC in CubeMX for discontinuous mode, then write a small snippet in HAL_ADC_MspInit() or after initialization to set the BULB bit.
It’s a bit of register-level tweaking, but once set, it gives reduced latency for high-impedance or fast-triggered signals.
2025-11-10 8:52 AM
You want to look for example code using ADC with DMA.
2025-11-10 9:38 AM
Bulb Sampling Mode in STM32G4 ADCs enables reduced latency between conversions in discontinuous mode, making it suitable for high-impedance sources and applications where fast response to triggers is required. It is configured via the BULB bit, with specific compatibility and timing limitations.
+
The official STM32 documentation does not provide direct information on enabling Bulb Sampling Mode via STM32 HAL library functions. The context focuses on register-level configuration and does not mention a specific HAL API or function for this feature. Therefore, enabling Bulb mode may require direct register manipulation rather than a dedicated HAL function.
So just set the bit by a direct write. ( ADCx->CFGR2 .... see rm , what you want/need to set )
2025-11-10 10:16 AM
Bulb Sampling Mode on STM32G4 ADCs isn’t directly exposed through CubeMX or HAL functions, so you’ll need to manipulate the registers directly. Key points:
Mode Activation – Set the BULB bit in ADCx->CFGR2 (check the reference manual for exact bit position).
Compatibility – Only works in discontinuous mode; not compatible with continuous conversion or injected channels.
Sampling Time – Bulb mode takes effect from the second conversion onward, and the first conversion uses the programmed sampling time. Maximum sampling time is limited—check the datasheet.
SMPTRIG – Make sure the SMPTRIG bit is not set when using Bulb mode.
DMA – For high-speed applications, pair with DMA to capture conversions efficiently.
In practice, you configure the ADC in CubeMX for discontinuous mode, then write a small snippet in HAL_ADC_MspInit() or after initialization to set the BULB bit.
It’s a bit of register-level tweaking, but once set, it gives reduced latency for high-impedance or fast-triggered signals.
2025-11-10 10:20 AM
Hello @jeffs555 ,
There is No ready-to-use example for STM32G4 ADC Bulb mode. So, you can start your ADC project and configure manually the ADC peripheral with Bulb sampling mode. This is enabled by setting the BULB bit in the ADC_CFGR2 register.
Make sure the ADC is configured in discontinuous mode, as Bulb mode is only available in this mode and is not compatible with continuous conversion or injected channel conversion.
Ensure the SMPTRIG bit in ADC_CFGR2 is not set, as it is incompatible with BULB mode.
Please check the following resources that may help you in your configuration :