Timer nRF52833 problem when using PWM+ble_app_uart+libuartes

Hi I'm developing an application using using PWM+ble_app_uart+libuartes.  So I have 2 questions
1. I'm using PWM to ring the buzzer a simple  melody.
What is the example I should you ?And what is common frequency when using PWM to rinng the buzzer?
2. I merger the code ble_app_uart and libuartes using 2 libuartes and It's work fine. I find that this application using 3 Timers. Soft Device(Timer0), Timer1, Timer2 used for libuartes.
According to nRF52833 document, nRF52833 have 5 Timers. So how can I use the rest timers for PWM (initialize, generate..)? 
Thank you, hope your reply soon !

  • Sorry. Seems like I wrote the last reply after you wrote the last question, so your ticket fell out of my queue.

    I think you should have a look at the Thingy SDK. The Thingy52 uses a buzzer and PWM to play short sound clips. These clips are not .wav format, so I guess someone has ported it into PWM frequencies. 

    There are some fundamental differences between playing a tone/note on a buzzer and playing a sound clip. When you are playing a simple tone, it is just a single frequency, but if you intend to play a sound clip, you need to use the PWM to mimic a DAC (digital to analog converter), so higher PWM duty cycles will generate a higher analogue output voltage for a short period of time. This is complex, but you can have a look at the SDK for Thingy. Find this download:

    Download it and search for "drv_speaker_sample_play" to see how it plays the different sound clips. 

    Warning: This is not trivial. It is much easier to just play a few notes using a buffer.

Related