Skip to main content
Visitor II
November 10, 2025
Question

STM32G4 How to enable ADC Bulb sampling mode using HAL and CubeMX?

  • November 10, 2025
  • 3 replies
  • 187 views

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?

    This topic has been closed for replies.

    3 replies

    Graduate II
    November 10, 2025

    You want to look for example code using ADC with DMA.

    Super User
    November 10, 2025

    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.

    • Mode Activation: Bulb mode is configured by setting the BULB bit in the ADC register.
    • Compatibility: It is only available in discontinuous mode and is not compatible with continuous conversion mode or injected channel conversion.
    • Register Settings: When the BULB bit is set, the SMPTRIG bit must not be set.
    • Sampling Time: The maximum sampling time in Bulb mode is limited and should be checked in the device datasheet.
    • Operation: The very first conversion uses the programmed sampling time; Bulb mode is effective from the second conversion onward.

    +

    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 )

     

     

    Technical Moderator
    November 10, 2025

    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.

    ImenD_0-1762797720363.png

    Please check the following resources that may help you in your configuration :