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

High frequency PWM shifts phase when radio is active

image description

When setting up a 1Mhz square wave using NRF_PWM on the NRF52 or GPIOTE on the NRF51 while BLE is advertising, the PWM stops when the radio is active. The problem doesn't happen when the frequency is below 6khz. No PWM interrupt is enabled. Is this an unavoidable limitation with high PWM frequencies?

  • The problem refers to the output waveform's frequency, not the frequency at which the PWM clock is being driven.

  • Sorry I need to be more specific: I can imagine that you will have problems with some PWM playback configurations (e.g. having some "silent" windows like you show on screenshot above) on nRF51 when extensive BLE activity happens. Guys from Nordic could suggest the most optimal way of using PPI, TIMER and GPIOTE to achieve your goal but this is out of my scope. However on nRF52 with its specific driver (which is using PWM peripheral existing only on nRF52 not nRF51) you can make it work easily through nrf_drv_pwm in the latest SDK. At least this is what I see on my demo project.

  • Looks like the PWM isn't dropping out but shifting in phase when the radio is active. The oscilloscope is sampling at 100khz, showing only an alias of the 1Mhz waveform. The phase shift nulls the alias. The phase shift could still be affecting our gadget, but it's hard to get a high enough samplerate yet capture a long enough waveform to see it.

  • Well as PWM is basically digital interface could you use some fast digital analyzer e.g. Saleae Logic PRO? They are cheap (usually available at each bigger lab) and they can sample at >8MHz frequency for longer time (I routinely use Saleae Logic PRO at 50MHz to capture >5min sequences). You should then see where and how PWM output is corrupted. I'd still say that your "bare metal" example (writing directly to the registers) above isn't enough. PWM on nRF52 is able to "play" set of values in the loop thanks to the "decoder" and 2 "sequence" buffers but I don't see it used in your code (which is probably compatible with nRF51?). I'd suggest to look on nRF52 specific driver as suggested in my answer.

    Cheers

  • Tested the NRF_PWM code on PCA10040 v1.0.1 with ble_app_template example and it works like it should. I would rather believe there is something wrong with the measurement tools. A logic analyzer with a higher sampling rate would be more fitting here as endnode says.

Related