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

watchdog reset after PWM

Hello,

I'm playing beep sound using pwm1 (timer1).

The onSound() starts beep sound.

The disableBuzzer() terminates pwm1.

The handler_buzzer() selects continuous sound playback or pwm1 termination.

  • Abnormal condition with log message
  1. The "buzzer stop" does not occur and the watchdog reset(2 sec) occurs intermittently.

  2. Even if "buzzer stop" is output, there is no buzzer sound and watchdog reset (2 sec) occurs intermittently.

I am wondering if there is a problem with the code. I use nrf51822/SDK 12.1.0. I need help.

thanks.

void onSound(uint8_t Num)
{
	NRF_LOG_PRINTF("buzzer start\r\n");

//	offSound();
	BUZZER_USE;

	if(Num != BEEP_DOOR_ALARM)
		doorAlarmBeepCnt = 0;						// door open alarm beep cancel

	beepOrder = 0;
	beepCnt = beepCntInfo[Num];
	soundNum = Num;

	makeSound(beepLevel[soundNum][beepOrder]);
	controlLed(ledInfo[soundNum][beepOrder]);
	timerBuzzer(START, beepTime[soundNum][beepOrder]);			
}

void disableBuzzer(void)
{
	ret_code_t err_code;

	timerBuzzer(STOP, NULL);			
	app_pwm_disable(&PWM_BUZZER);
//	err_code = app_pwm_end(&PWM_BUZZER);
//	APP_ERROR_CHECK(err_code);

	nrf_gpio_pin_clear(BUZZER_PIN);
	nrf_gpio_cfg_output(BUZZER_PIN);

	BUZZER_NO_USE;
	NRF_LOG_PRINTF("buzzer stop\r\n");
}


void makeSound(uint16_t level)
{
	ret_code_t err_code;

	err_code = app_pwm_uninit(&PWM_BUZZER);
//	APP_ERROR_CHECK(err_code);
//	app_pwm_disable(&PWM_BUZZER);
	app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(level, BUZZER_PIN);
	pwm1_cfg.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_HIGH;

	err_code = app_pwm_init(&PWM_BUZZER, &pwm1_cfg, NULL);			// callback_pwmBuz);
	APP_ERROR_CHECK(err_code);
	app_pwm_enable(&PWM_BUZZER);

	// sound level check
#if !TEST_SOUND_OFF
	if(fireStatus)
		while(app_pwm_channel_duty_set(&PWM_BUZZER, 0, SOUND_MAX) == NRF_ERROR_BUSY);
	else if(batteryStatusSave <= BATTERY_LOW)
		while(app_pwm_channel_duty_set(&PWM_BUZZER, 0, SOUND_MIN) == NRF_ERROR_BUSY);

	else if(soundLevelTemp == 0)
		while(app_pwm_channel_duty_set(&PWM_BUZZER, 0, soundLevelInfo[lockInfo.soundLevel]) == NRF_ERROR_BUSY);
	else
		while(app_pwm_channel_duty_set(&PWM_BUZZER, 0, soundLevelTemp) == NRF_ERROR_BUSY);
#else
	while(app_pwm_channel_duty_set(&PWM_BUZZER, 0, SOUND_OFF) == NRF_ERROR_BUSY);
#endif
}

void handler_buzzer(void * p_context)
{
	UNUSED_PARAMETER(p_context);	  

	beepOrder++;
	beepCnt--;

	if(beepCnt)
	{
		timerBuzzer(START, beepTime[soundNum][beepOrder]);			
		makeSound(beepLevel[soundNum][beepOrder]);
		controlLed(ledInfo[soundNum][beepOrder]);
	}
	else
	{
		disableBuzzer();
		soundLevelTemp = 0;
   }
   
   
}
  • Is this System OFF or System ON sleep ? I assume that you are using GPIOTE for the button? The nRF51 has only 4 GPIOTE channels and the PWM library uses one per PWM channel. So if you run out of GPIOTE channels you will get the NRF_ERROR_NO_MEM error.

  • It's system on sleep. I use GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS : 12. I checked to use more than 4 channels from your co-worker. And I think this problem is related with the app_timer. I asked this today.

    Hellow,

    I'm using app_timer to play the buzzer.

    The default behavior is 1. key in 2. timer start: 8Sec for key action stop check 3. Buzzer on (pwm1) 3. buzzer timer start 4. Buzzer timer stop. 5. buzzer off

    The odd thing is 1. Abnormal termination of the timer occurs. - The 8 second timer in process 2 is terminated as soon as it starts. - Due to this phenomenon, abnormal operation of the buzzer makes the overall wrong operation. Below is a log message. The current issue is being debugged for a few days now. Help is urgently needed.

    Thank you.

    // * normal message 0> key in : touch 1 0> key action : touch 1 0> timer - normal start 0> buzzer start 0> buzzer timer start : 0 0> pwm-buzzer uninit error : 0 0> pwm-buzzer init error : 0 0> pwm-buzzer enable 0> pwm-buzzer duty set 0> sleep 0> buzzer timer stop : 0 0> timer handler 0> buzzer timer start : 0 0> pwm-buzzer uninit error : 0 0> pwm-buzzer init error : 0 0> pwm-buzzer enable 0> pwm-buzzer duty set 0> sleep 0> buzzer timer stop : 0 0> timer handler 0> buzzer stop 0> sleep *

    // * abnormal message 0> key in : touch 1 0> key action : touch 1 0> timer : normal start 0> buzzer start 0> timer : normal end --->>> abnormal timer stop !!!!!!! 0> buzzer start --->>> another buzzer start when time stopped : not acceptable !!! 0> buzzer timer start : 0 0> pwm-buzzer uninit error : 0 0> pwm-buzzer init error : 0 0> pwm-buzzer enable 0> pwm-buzzer duty set 0> buzzer timer stop : 0 0> buzzer timer stop : 0 0> timer handler 0> buzzer timer start : 0 0> pwm-buzzer uninit error : 0 0> pwm-buzzer init error : 0 0> pwm-buzzer enable 0> pwm-buzzer duty set 0> buzzer timer stop : 0 0> timer handler 0> buzzer stop 0> buzzer timer start : 0 0> pwm-buzzer uninit error : 0 0> pwm-buzzer init error : 0 0> pwm-buzzer enable 0> pwm-buzzer duty set 0> sleep 0> sleep *

Related