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

piezo buzzer has to generate sound until event occurs

i successfully generated sound using pwm and piezo buzzer

while(/*while event occurs*/)
{
	for (uint8_t i = 0; i < 50; ++i)
	{
		value = (i < 20) ? (i * 5) : (100 - (i - 20) * 5);
		/* Set the duty cycle - keep trying until PWM is ready... */
		while (app_pwm_channel_duty_set(&PWM1, 0, value) == 
	}
}

how to turn off the sound, if i given any flag it is not coming out of the while .

Related