strange signal / noise on PWM. Noise diaspears when connecting to JLINK! WHY?

Hi,

i am using a PWM signal to control the brightness of a LED. When the brightness is at zero, i have a random flickering on the LED.

This signal is also present at the pin itself. The strange thing, as soon i connect a JLINK probe the signal is perfect zero. So no noise anymore.

As soon i remove the JLINK the flickering is back.

Annoing magic.

Any idea why the JLINK influnces the behaviour of the nRF52?

thank you

Max

Parents Reply Children
  • PWM init:

    void pwm_init(void)
    {
        /* Config PWM 0*/
        nrf_drv_pwm_config_t const config0 =
        {
            .output_pins =
            {
                LED_SPOT , // channel 0
                LED_WIDE ,  // channel 1
     
            },
            .irq_priority = APP_IRQ_PRIORITY_LOWEST,
            .base_clock   = NRF_PWM_CLK_8MHz,
            .count_mode   = NRF_PWM_MODE_UP,
            .top_value    = 100,
            .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
            .step_mode    = NRF_PWM_STEP_AUTO
        };
        APP_ERROR_CHECK(nrf_drv_pwm_init(&m_pwm0, &config0, NULL));
    
    }
    

    Update duty cycle:

    // Set duty cycle between 0 and 100%
    void pwm_spot_update_duty_cycle(uint8_t duty_cycle)
    {
        uint8_t invert = 100 - duty_cycle;
        static uint8_t pwm_test_spot; 
        // Check if value is outside of range. If so, set to 100%
        if(invert >= 100)
        {
            seq_values.channel_0 = 100;
        }
        else
        {
            seq_values.channel_0 = invert;
        }
    
        pwm_test_spot = 
        
        nrf_drv_pwm_simple_playback(&m_pwm0, &seq, 1, NRF_DRV_PWM_FLAG_LOOP);
    }
    
    // Set duty cycle between 0 and 100%
    void pwm_wide_update_duty_cycle(uint8_t duty_cycle)
    {
        uint8_t invert = 100 - duty_cycle;
      
        // Check if value is outside of range. If so, set to 100%
        if(invert >= 100)
        {
            seq_values.channel_1 = 100;
        }
        else
        {
            seq_values.channel_1 = invert;
        }
        
        nrf_drv_pwm_simple_playback(&m_pwm0, &seq, 1, NRF_DRV_PWM_FLAG_LOOP);
    }

  • Try using nrf_drv_pwm_sequence_values_update() instead of nrf_drv_pwm_simple_playback() to change the duty cycle.

  • according some examples i implemented the following:

    static nrf_pwm_values_individual_t seq_values[];

     seq_values[0].channel_0 = 50;
      seq_values[0].channel_1 = 50;

      nrf_pwm_values_t new_pwm_values;

      new_pwm_values.p_individual = seq_values;

    nrf_drv_pwm_sequence_values_update(&m_pwm0, 0, new_pwm_values);

    But now i dont have any PWM output !

  • How do you start the PWM now? I think you need to call nrf_drv_pwm_simple_playback() before you call nrf_drv_pwm_sequence_values_update.

  • but you told me to usenrf_drv_pwm_sequence_values_update instead of nrf_drv_pwm_simple_playback()

Related