I'm trying to drive the RGB LED light on the Thingy:91. So far, I've not been successful. I was hoping that by listing the steps I perform I might be able to get some advice. This is the first time that I've dealt with PWM. Here are the steps I'm presently taking:
1. Using PWM0_NS (my program is insecure), assign pins p0_29, p0_30, and p0_31 having set them up as push/pull output with an initial level of high.2. Set the period of the PWM to 500hz.3. I then loop around wanting to toggle the LED on and off by setting the duty of all three channels to the max duty (on) and 0 (off) with about 1 second sleep in between.
Does this approach seem reasonable? I really want the simplest PWM RGB LED demo I can; think of blinky for the RGB LED.
Thanks for any help.
Zephyr provides a straightforward sample showing how to control an LED with a PWM peripheral.
You can find it in your ncs folder: ../zephyr/samples/basic/blinky_pwm.
It doesn’t work…
the Zephyr example uses a duty cycle of 50% changing the frequency up- and downwards. The maximum frequency is dependent on the wave counter and its prescaler, which is why the “self-calibration” was added to this application.
Could you elaborate what kind of issue you exactly have? Are you able to make the LEDs blink at all?
I can make the lights now blink on the nRF9160-dk with the max duty cycle. I'll try again with the Thingy:91 and 50% of the max. I'll get back to you shortly. Thanks.
OK, I tried 50% of the max duty. No cigar.
Would I be pushing the friendship to show you the code in full? :-)
Just to close this off, all now appears well. I'm thinking that something just got "stuck" somewhere... After building and flashing the Zephyr example again, I then erased the board, added the spm and flashed my Rust code. It works! Thanks for your help. I'll mark your initial reply as the answer as it helped.
Thanks a lot for the feedback, Christopher! I am pleased to hear that your application works now :-)