Here are the details about my development environment:
SDK = 15.3.0
IDE = SES
SoC = nRF52840-based BL654 module.
In my design, I need to drive a buzzer with the PWM signal. I've seen many PWM examples that deal with the complex playing sequences. What I need, however, is to play PWM that has constant duty cycle but variable frequency. Moreover, I would like, if possible, to change PWM frequency automatically, without CPU intervention (i.e. without event handlers).
Is there any way I can do this? By looking at this thread, I've learned that PWM hardware is intended for use cases where the duty cycle is changing and if I want to change the PWM frequency, I need to uninit and re-init the PWM hardware. This uninit - reinit process is quite fast to be perceived by a human ear. Withing the same thread they suggest a possibility to use a timer and GPIO with PPI for implementing the signal with variable frequency.
What is your opinion, guys, is there any way I could change PWM frequency parameter automatically, on-the-fly, without any CPU intervention (in DMA mode)?
Thanks in advance for your time and effort.
Yes, there is a waveform mode that can change both frequency and duty cycle. Here's its description from spec:
A special mode of operation is available when DECODER.LOAD is set to WaveForm. In this mode, up tothree PWM channels can be enabled - OUT to OUT. In RAM, four values are loaded at a time: thefirst, second and third location are used to load the values, and the fourth RAM location is used to load theCOUNTERTOP register. This way one can have up to three PWM channels with a frequency base thatchanges on a per PWM period basis. This mode of operation is useful for arbitrary wave form generation inapplications such as LED lighting.
Thank you very much for pointing out that for me. Indeed, I was able to benefit from the PWM waveform mode!
Thanks once again!