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 !

Parents
  • Hello,

    What is the example I should you ?And what is common frequency when using PWM to rinng the buzzer?

    That depends on the buzzer, I guess. Just remember that buzzers typically changes tone on frequency, and not PWM duty cycle. So try setting the duty cycle to 50%, and change the frequency to change the tone. 

    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..)? 

    That is correct. I believe you don't need more than one timer for the PWM.

    BR,
    Edvin

  • Hi Edvin,
    1. Can you give me some hint to play a sound (wav.file) or melodic sound by buzzer as simple as possible. The buzzer I use is the buzzer used for mobile phone.
    2. How to change different frequency continuously in run time ?

  • 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.

Reply
  • 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.

Children
No Data
Related