This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I want to use PWM on only one output pin

I want to use PWM on only one output pin. I'm using a nrf51422 and softdevice s130.

I want to be able to set the PWM and then change it again (a sequence). This is to be able to generate sounds through a buzzer.

Is there a simple example I can look at.

Parents
  • We have a PWM example in SDK 11 that uses the PWM library to change the duty cycle between 0 and 100 percent.

    To generate different sounds through a buzzer you have to change the frequency of the signal to the buzzer. Either change the frequency of the PWM directly or modulate a sine wave and change the frequency of the sine wave. You cannot change the frequency of the PWM without reinitializing the PWM instance. I have not tried to modulate a sine wave with the PWM library, but I suspect that it is too slow. You may give it a try and see if it works.

  • On second thought modulating a sine wave may not work depending on other things running in the system. The duty cycle update may be delayed which will destroy the modulation.

    Yes it is compatible with S130. Use TIMER1 or TIMER2. You should not be allowed to use TIMER0 if SOFTDEVICE_PRESENT is defined.

Reply Children
No Data
Related