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

how to stop pwm and set pin to clear

Hi,all.i use pwm with sdk8.1 sample (SDK8.1\example\peripheral\pwm),my question is how to stop pwm and set the pin to low level? is my code correct? my pwm init code:


static uint32_t init_pwm(uint32_t perior,uint8_t pin)
 {	 
	 	uint32_t err_code = 0; 
    /* 2-channel PWM, 200Hz, output on DK LED pins. */
	  app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(perior, pin);
	 
	 pwm1_cfg.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_LOW;
    
    /* Initialize and enable PWM. */
    err_code = app_pwm_init(&PWM1,&pwm1_cfg,pwm_ready_callback);
    APP_ERROR_CHECK(err_code);

    return err_code;
}
------------------------------------------------------------------------------

pwm stop code:
void pwm_stop( void )
{
   app_pwm_disable(&PWM1);
}
----------------------------------------------------------------------------

pwm start code:
void pwm_start( void )
{   
   app_pwm_enable(&PWM1);
}
Related