Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to change a pin between GPIO and PWM

Hi There

My design is basic on nrf52840. I need a pin be controlled alternately by GPIO module and PWM module in my application. The PWM function is realized by setting the PWM hardware module, as in the SDK example (nRF5_SDK_16.0.0_98a08e2\examples\peripheral\pwm_driver).

My question is:

Q1. May I  return the pin to GPIO control by just setting the PSEL.OUT[n]. C to 1?  Or do I have to clear the pin number from A so that the pin will go to GPIO control?

Q2.Is there anything you need to pay attention to when implementing pin control conversion between GPIO and PWM?

Q3. Is there a better way to do it

Thanks,

Di-sheng

Related