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.

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

Children
Related