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

What is the max frequency the PWM peripheral can produce on the nRF51822?

I want to drive motors at 40kHz and am wondering if I will be able to do this with the nRF51822. If not 40kHz, I might be able to go as low as 15kHz. What is the resolution and maximum frequency I can generate while also using the S110 soft device (e.g. maintaining ble communications).

  • Hi

    The implementation in this PWM library should be pretty much independent of the CPU. Only if you intend to update the PWM duty cycle you need to use the CPU.

    The CPU is blocked for some time during BLE radio transmission but the PWM will still be uninterrupted since it is maintained by TIMER+PPI+GPIOTE hardware peripherals which do not need the CPU. So I think 40kHz should be no problem. You might experience though up to 6ms delay when you want to update the duty cycle of the PWM, since the softdevice can block the CPU for up to 6ms.

  • To generate a sine wave at 40 kHz, the PWM duty cycle has to be updated x times as many times, where x is the amount of points in the sine wave. For a gritty sine wave with 25 points you would already need to update the duty cycle at 1 MHz. In the examples you show the CPU is also used to update the sine waves. The maximum PMW frequency I managed to get is 250 kHz and a maximum duty cycle update frequency of 8 kHz, which is by far not enough to make a sine wave at 40 kHz.

  • Thanks for your update GEUZE. I can agree that driving AC motor with the nRF51 PWM is quite limited in terms of frequency of the sine wave. Also if you are doing BLE transfer at the same time you will experience slower update frequency of the PWM as the CPU may be busy during BLE connection event. More information on the CPU availability during connection event is given in the Softdevice Specification (chapter about "Processor availability and interrupt latency") for the softdevice in question.

    The nRF52832 engineering and production versions will have PWM hardware peripherals that can update the duty cycle as well without use of CPU. For AC motor control, nRF52832 should be a valid option. The PWM perhipherals are however currently not available in the nRF52832 preview chip but will be available in the upcoming nRF52832 engineering release, scheduled for October 2015.

Related