PWM jitter or flicker using nrf5_SDK_for_Mesh_v5 dimming example

I am connecting the nRF52 DK to an oscilloscope and on the LED pin for the dimming example on the server side. I am seeing jitter, the PWM duty cycle doing a slight shift every 2.5 seconds or so. When I decrease the frequency from 5 kHz to 2.5 kHz the jitter happens even more frequently but is cyclical, below is a video of what we are seeing. 

When I disable the start() before the main loop this issue in the PWM goes away. Is there something that is happening in the mesh to reset the PWM each time or something else? What is going on here?

int main(void)
{
    initialize();
    m_pwm0_present_level = 0;
    pwm_utils_level_set(&m_pwm, m_pwm0_present_level);
    //start();

    for (;;)
    {
        (void)sd_app_evt_wait();
    }
}

Thank you, 

Sky

Parents
  • Hi Sky

    This is probably caused by the RF protocol switching on the external 32MHz clock whenever the radio is going to be used, thereby causing a slight switch in the clock to the PWM module. 

    In order to prevent this issue you can request the 32MHz clock be enabled constantly (or at least as long as you are running the PWM). 

    When the SoftDevice is used you can do this through the sd_clock_hfclk_request() function. 

    Best regards
    Torbjørn

  • Torbjorn, 

    I just tried commenting out this line below in the start() and the problem went away. I'm not gong to use the rtt anyway because I am sending data based on a UART input interrupt.

    I didn't try enabling the clock constantly because this did the trick. I figured that it might have something to do with a timer or clock. This is solved.  

    //rtt_input_enable(app_rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);

    Thank you,

    Sky

Reply
  • Torbjorn, 

    I just tried commenting out this line below in the start() and the problem went away. I'm not gong to use the rtt anyway because I am sending data based on a UART input interrupt.

    I didn't try enabling the clock constantly because this did the trick. I figured that it might have something to do with a timer or clock. This is solved.  

    //rtt_input_enable(app_rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);

    Thank you,

    Sky

Children
Related