This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

[PWM-DRIVER] Pull up/pull down pins use for PWM driver

Hi everyone,

I am making a project to dim a led strip following PWM driver example, everything works pretty well but i only have one problem that I need to set a state for the pins before doing any dimming so that it will not turn on/off suddenly during reset or start up in float state. But i can not find any way to set that value in the example or document.

So i have a question that: Is there any way I can set the PWM pins to be pull up or pull down before doing and PWM dimming?

Thank you and please reply soon

Parents
  • Hi,

    You can select the initial pin state by using NRF_DRV_PWM_PIN_INVERTED, before you start any dimming(with nrf_drv_pwm_simple_playback/nrf_drv_pwm_complex_playback  ). The pin state will be set when you call nrf_drv_pwm_init().

    Snippet:

     nrf_drv_pwm_config_t const config0 =
        {
            .output_pins =
            {
                BSP_LED_0 | NRF_DRV_PWM_PIN_INVERTED, // channel 0
                BSP_LED_1 ,                           // channel 1
                BSP_LED_3 | NRF_DRV_PWM_PIN_INVERTED, // channel 2
                BSP_LED_2 | NRF_DRV_PWM_PIN_INVERTED  // channel 3
            },
            .irq_priority = APP_IRQ_PRIORITY_LOWEST,
            .base_clock   = NRF_PWM_CLK_1MHz,
            .count_mode   = NRF_PWM_MODE_UP,
            .top_value    = m_demo1_top,
            .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
            .step_mode    = NRF_PWM_STEP_AUTO
        };
        APP_ERROR_CHECK(nrf_drv_pwm_init(&m_pwm0, &config0, demo1_handler));
        m_used |= USED_PWM(0);

Reply
  • Hi,

    You can select the initial pin state by using NRF_DRV_PWM_PIN_INVERTED, before you start any dimming(with nrf_drv_pwm_simple_playback/nrf_drv_pwm_complex_playback  ). The pin state will be set when you call nrf_drv_pwm_init().

    Snippet:

     nrf_drv_pwm_config_t const config0 =
        {
            .output_pins =
            {
                BSP_LED_0 | NRF_DRV_PWM_PIN_INVERTED, // channel 0
                BSP_LED_1 ,                           // channel 1
                BSP_LED_3 | NRF_DRV_PWM_PIN_INVERTED, // channel 2
                BSP_LED_2 | NRF_DRV_PWM_PIN_INVERTED  // channel 3
            },
            .irq_priority = APP_IRQ_PRIORITY_LOWEST,
            .base_clock   = NRF_PWM_CLK_1MHz,
            .count_mode   = NRF_PWM_MODE_UP,
            .top_value    = m_demo1_top,
            .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
            .step_mode    = NRF_PWM_STEP_AUTO
        };
        APP_ERROR_CHECK(nrf_drv_pwm_init(&m_pwm0, &config0, demo1_handler));
        m_used |= USED_PWM(0);

Children
No Data
Related