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

SDK14 nRF52 PWM module and BLE example?

Is there an example of using the nRF52's PWM module and BLE at the same time using SDK14 / GCC ?

  • Fo anyone that whats to try then please see here: devzone.nordicsemi.com/.../

    Pasting the 'pwm_simple()' function and making a call of the code prior to the infinite loop of HRS example worked a lot better than trying to reuse the SD"s PWM driver '5demo' example.

    The SDK13 zip update in the answer of that post works fine with SDK14.

    You also need to adjust the make file, here's a diff of what's worked for me.

    44a45
    >   $(SDK_ROOT)/components/drivers_nrf/pwm/nrf_drv_pwm.c \
    215a217,221
    > CFLAGS += -DPWM_ENABLED=1
    > CFLAGS += -DPWM0_ENABLED=1
    > CFLAGS += -DPWM1_ENABLED=1
    > CFLAGS += -DPWM2_ENABLED=1
    > CFLAGS += -DAPP_PWM_ENABLED=1
    
  • It occurred to me that it might be useful to add a bit of context...

    The reason I asked in the first place was that once PWM was setup and then later when I performed a nrf_drv_pwm_uninit and then nrf_drv_pwm_init within the BLE NUS event handler to set PWM sequence based on GATT supplied data there was a HardFault occurring.

    So, I thought it wasn't possible to perform the PWM change in the BLE handler and/or I needed to go via a SoftDevice API, turns out the nrf_drv_pwm_uninit wasn't being called correctly.

    It seems ok now, but I do wonder if the PWM update request should be queued and executed within the context of the App Scheduler. I couldn't find anywhere in the docs where it explicitly says 'PWM init/deinit is ok in a IRQ and Event handlers'.

Related