I think there are several methods you ay use.
You could have an interrupt routine that beeps for a short time, repeatedly. In the interrupt set a flag that increments with each very short beep until it has been on long enough then, disable the interrupt. Pseudo code:
INTERRUPT:
Flag = flag + 1
Make short beep
if flag = 100 then flag = 0 and turn off interrupt
Main:
If error then turn on interrupt
code
code
goto Main
Or, as an alternative, you could make or buy a buzzer module. When you need noise, turn it on with a single pin, when you don't - turn it off same way.
Or, as you suggest your PWM pin is free, wire up the buzzer there. As PWM runs independently of code...
Bookmarks