Hello,
I'm having a bit of difficulty disabling the PWM peripheral when it is no longer required. From the manual it states that "To completely stop the PWM generation and force the associated pins to a defined state, a STOP task can be triggered at any time.", so I have triggered a TASKS_STOP call followed by disabling the peripheral with ENABLE but it doesn't seem to stop the PWM driven pins.
void pwm_control(CTRL *pCtrl, bool enable) { #if CONFIG_PWM { if(enable && !pCtrl->System_PWM.bPWMEnable) { printk("Enabling PWM\n"); NRF_PWM1_NS->ENABLE = 1; NRF_PWM1_NS->TASKS_SEQSTART[0] = 1; pCtrl->System_PWM.bPWMEnable = true; } else if (!enable && pCtrl->System_PWM.bPWMEnable) { printk("Disabling PWM\n"); NRF_PWM1_NS->TASKS_STOP = 1; NRF_PWM1_NS->ENABLE = 0; pCtrl->System_PWM.bPWMEnable = false; } else { printk("Error, PWM control undetermined\n"); } } #endif }
What I see is that if I place the above function after a call to pwm_pin_set_usec(), the PWM driven pin is still driven, e.g. the Thingy:91 RGB LED is still illuminated, and any future calls to pwm_pin_set_usec() run as normal with no issues. What is the correct method to disable the PWM perpiheral on the nRF9160 during runtime?