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

buzzer pwm&power

FormerMember
FormerMember

I want to use the pwm to control buzzer, but when I use init function, the power will increase 880 uA, how to decrease the power.

void beep_on(void)//beep on
{
	  app_pwm_channel_duty_set(&PWM1, 0, warning_voice);
}

void beep_off(void)
{
		app_pwm_channel_duty_set(&PWM1, 0, 0);  
}

void beep_on_on(void)
{
		beep_pwm_init();
}
void beep_off_off(void)
{
	  app_pwm_uninit(&PWM1);//in this 
		nrf_gpio_cfg_output(BEEP);							
		nrf_gpio_pin_clear(BEEP);
}
bool ready_flag1=0;
void pwm1_ready_callback(uint32_t pwm_id)    // PWM callback function
{
    ready_flag1 = true;
}
void beep_pwm_init(void)
{
		app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(260,BEEP);//(250L,1,9);//
		pwm1_cfg.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_HIGH;
	  app_pwm_init(&PWM1,&pwm1_cfg,pwm1_ready_callback);
    app_pwm_enable(&PWM1);
		app_pwm_channel_duty_set(&PWM1, 0, 0);
}

1、first, I use beep_pwm_init() before for(;;), and the testing instrument display the power is increase 880uA. and then, I use beep_on() and beep_off() to start or stop the buzzer. and the connection is good, not always disconnected.

2、I use another way. I use beep_on_on() function when I want the buzzer work, and when I want the buzzer off, I use the beep_off_off(), the power is decreased, but the connection is no longer stable.

please help me to over come this question, thanks.

Related