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

pwm library continuous change with softdevice not working

Hi Guys,

once again, I have strange behavior of my code.

In my code I try in loop after ble_event received change PWM from 0 to 255 for my motor device. In debug logs, I can see continuous change value with 100ms delay (I tried also 500ms), but instead of slowly speed-up I can not see any motor movement. Here comes weird things. Then I change value back from 255 -> 0 (on logs everything looks good) but motor start working at maximum. Based on observations, it seems, PWM react only on 1st change at the time because when I set only one value, it works like charm.

This is my setup:

  • nrf51822 rev. 3
  • Softdevice 8.0.0
  • SDK 9.0.0
  • pwm library (latest version), nrf_pwm_noglitch
  • PWM working in general

Do you have any idea what is going on, or how should fix this issue?

Parents Reply
  • There was a lot of bugfixes and improvements, so I would recommend using app_pwm from SDK 10 anyway. Note that app_pwm requires some time to change the duty cycle (up to 2 periods). To make a change when PWM is busy, you have to wait until the previous operation is complete. Waiting in interrupt (BLE event handler or timer handler) blocks the execution of lower/equal priority tasks. App_scheduler is a good option here - task can be queued in interrupt and executed in app_sched_execute() from main context.

Children
No Data
Related