Hi..
i am using a 5V dc buzzer which makes a beep sound when 5V is applied to it. Its the same as you would find inside a PC casing. My buzzer some times beeps and some times it just make a click noise. it is run be a uC.
So the uC current capability looks ok. Logically, then, something is amiss with the uC software. Could interrupts be over-riding the buzzer drive arrangement?
So the uC current capability looks ok. Logically, then, something is amiss with the uC software. Could interrupts be over-riding the buzzer drive arrangement?
My code is somthing like this. the internal sec is a global volatile variable which gets ++ in an ISR routine @ 250ms.
Code:
if ( internal_sec%16==0 ) //blink the water change activity led
{ PORTC |= 1<<PINC1; } else { PORTC &=~(1<<PINC1);LCDWriteIntXY(0,1,val,4); }
ISR(TIMER1_COMPA_vect) // action to be done every 250 msec
{
internal_sec++;
if (internal_sec > 239) //convert it to 1000msec
{
internal_sec = 0;
internal_min ++; //we get 1 min after every 60 sec
if (internal_min ==240) // gives 4 hr timing
{
internal_min = 0;
}
}
}
i can change the "internal_sec%16==0" to lets say 2 to make the beep 500ms long. but that does not help the clicking.
Sounds more like a faulty buzzer.....I use little 5v buzzers... When it clicks i tap it with a screwdriver and it then makes the correct sound... My 5v buzzers really should be given 6V as I drive them through a NPN BJT and they don't get the full 5V they need..
I don't think the ISR is to blame either... This only counts time it doesn't set / reset any pin.
Sounds more like a faulty buzzer.....I use little 5v buzzers... When it clicks i tap it with a screwdriver and it then makes the correct sound... My 5v buzzers really should be given 6V as I drive them through a NPN BJT and they don't get the full 5V they need..
I don't think the ISR is to blame either... This only counts time it doesn't set / reset any pin.
while(1)
{
PORTC = 0x01; // buzzer on pin RC0
Delay_mS(250);
PORTC = 0x00; // buzzer off
Delay_mS(750);
}
That code will sit in a loop, beeping the buzzer once every second. If you turn your interrupt OFF first then this test will be a fairly bulletproof way to test your buzzer.