My microcontroller project has a small design mistake: I'm driving a small
> buzzer but I accidentally connected it to the wrong pin. It should have
> been connected to the OC0 pin which allows me to simply set the Timer0
> register and it will produce a PWM output with a certain frequency.
> Connecting the buzzer to the wrong pin forces me drive the buzzer 'manually.'
>
> So I'm planning to generate an timer interrupt and toggle the pin there
> but this will mean that the number of interrupts will equal the buzzer
> frequency, about 4000 hz in my case. The ISR (interrupt service routine)
> should be very small but I'm wondering if the AVR will be up to the task.
> Has anyone done something similar? BTW I'm driving the Mega-AVR with a
> 8Mhz crystal but I can upgrade it to 16Mhz if needed.
I once did a 10000 Hz ISR that does an update for 4 stepper motors, and sends the drive signals out on a 32 bit SPI chain. This was on an atmega128 using a 16MHz xtal. All code written in C. So, 4000 Hz with a simpler ISR should be fairly easy.. assuming of course you don't have too many other things going on.