I'm looking to add PWM functionality to my design to drive an LED. Examples exist for other devices, and those don't use the SoftDevice. Is there an example or some reference design for making the PWM module work with the nRF51822 and SD?
I'm looking to add PWM functionality to my design to drive an LED. Examples exist for other devices, and those don't use the SoftDevice. Is there an example or some reference design for making the PWM module work with the nRF51822 and SD?
Something strange is happening with this code. When I use PWM_NUM_CHANNELS 3 and use nrf_pwm_init(14, 8, 10, PWM_MODE_MTR_100); I get output on pin 14. But when I use PWM_NUM_CHANNELS 3 and nrf_pwm_init(14, PWM_MODE_MTR_100); for some reason the output is on pin 19! (LED_1 on the Evaluation Kit.) This is with the example above (not my own code).
Hi all
I agree an example like this would be useful in the SDK. Maybe we can get something like it in the future ;)
If you try to run pwm_init after enabling the SoftDevice it will trigger an exception. The reason for this is that pwm_init accesses the PPI peripheral directly, without going through the SoC Library API defined by the SoftDevice. It is possible to modify the PWM library to use the SoC Library, but then it will not work without the SD. This was the easiest way to make it work both with or without the SD.
The PWM output is assigned to actual pins a couple of times in the code, each time it is using the PIN configuration stored in the pwm_io_ch[] array. Please have a look in the PWM_IRQHandler function, where the pin is controlled either through the GPIOTE or by the nrf_gpio_pin_write() function.
Are you calling nrf_pwm_init with just 2 parameters when PWM_NUM_CHANNELS is 3? If you want to use just one PWM channel you should change the define to 1.