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

pwm always consume 300uA after app_pwm_init

Hi,

I am using PWM for a buzzer. It is working, but the current consumption is always 300uA when PWM is not in use. This minimal current consumption appears right after the app_pwm_init function and never stops.

Could you confirm that this implementation is correct? Should I initialize the PWM instance for every use or can I resue an instance like in the code below?

APP_PWM_INSTANCE(PWM1,1);                   // Create the instance "PWM1" using TIMER1.

void pwm_ready_callback(uint32_t pwm_id)    // PWM callback function
{
}

void buzzer_kernel_init(void)
{
	uint32_t err_code;
	uint32_t duty = 50;

	// PWM
	app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(250, WATCH_BUZZER_PIN_D);
	err_code = app_pwm_init(&PWM1,&pwm1_cfg,pwm_ready_callback);
	APP_ERROR_CHECK(err_code);
	
	app_pwm_enable(&PWM1);		
	// Set the duty cycle - keep trying until PWM is ready...
	while (app_pwm_channel_duty_set(&PWM1, 0, duty) == NRF_ERROR_BUSY);			
	app_pwm_disable(&PWM1);

	// Do bip
	app_pwm_enable(&PWM1);		
	nrf_delay_ms(50);		
	app_pwm_disable(&PWM1);

	nrf_delay_ms(50);

	// Do bip
	app_pwm_enable(&PWM1);		
	nrf_delay_ms(50);		
	app_pwm_disable(&PWM1);	
}

void buzzer_kernel_on(void)
{
		app_pwm_enable(&PWM1);		
}


void buzzer_kernel_off(void)
{   
		app_pwm_disable(&PWM1);	
}
Parents Reply
  • Thanks for pointing to those threads, I had not read them before. After reading them, I still think it is the proper way in order to save current and free resources to uninitalize the pwm module. I agree with you that initializing the pwm every time is a rather large operation but probably much cheaper in terms of current consumption than to just disable the pwm.

    Just to mention, nRF52 engineering release, has dedicated PWM hardware which will be much easier to manage and is more efficient. The PWM hardware is not available on the current nRF52 chip, but will be available on the engineering release of the nRF52 chip, scheduled for release in a few weeks

Children
No Data
Related