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

Shouldn't this function below output 2us Pulses, instead of outing 3us!

Hello

I am using nRF52 DK, I am trying to use PIN 30 as Pulse train. The following while loop is expected to send out Pulse train of 2microseconds period but instead, it is giving me 3-microsecond pulse width. which is weird or what is that I am missing here?

while(true)
{
//__WFE();
nrf_drv_gpiote_out_set(PIN_OUT_1);
nrf_delay_us(1);
nrf_drv_gpiote_out_clear(PIN_OUT_1);
nrf_delay_us(1);
}
}

SIgnal as on oscilloscope 

Seconds/Divison = 1us. 

Parents
  • You're missing execution delays, the nrf_delay_us() function is not entirely accurate, probably the least accurate at its lowest input value. It's implemented as assembly 'No Operation' instructions.

    Also the gpio functions has CPU execution time as well as the time-delay it takes to change the state of the pin. 

    If you want an accurate pwm signal you need to use TIMER+ PPI +GPIOTE. See the PPI example for details. 

      

  • I got your point, I noticed that GPIO is giving me an approximate pulse when in milliseconds. Would you mind to tell me what is the accuracy for PWM generated through TIMER+PPI+GPIOTE? So that I could decide whether to go for a seperate time to digital converter or use nRF52832 peripherals. and thanks for that response.

Reply Children
Related