Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Buzzer Routine Help

Status
Not open for further replies.

rrb011270

New Member
Mabuhay!

My buzzer routine below:
output_high(BUZZER);
delay_ms(200);
output_low(BUZZER);
delay_ms(450);

Is there another way such that I can use interrupt driven o reduce the instruction cycle of this routine?

My application is an RF reader which use an #int_ext2 to capture the ID from the badge. When it is successfull a buzzer will sound for success.

most of my code use the interrupt handler routine like the clock which use the #int_timer0 such it will capture the time and date and added to a complete packet of data which are compose of date, time, RFid, etc...

Any help will do?

Tenkyu
 
rrb011270 said:
Mabuhay!

My buzzer routine below:
output_high(BUZZER);
delay_ms(200);
output_low(BUZZER);
delay_ms(450);

Is there another way such that I can use interrupt driven o reduce the instruction cycle of this routine?

My application is an RF reader which use an #int_ext2 to capture the ID from the badge. When it is successfull a buzzer will sound for success.

most of my code use the interrupt handler routine like the clock which use the #int_timer0 such it will capture the time and date and added to a complete packet of data which are compose of date, time, RFid, etc...

Any help will do?

Tenkyu

Assuming you have a timer interrupt running, simple decrement a counter on each interrupt call, when the counter reaches zero, toggle the output pin and reload the counter with the next value (you could use different values to give the assymetrical waveform you are currently using). To turn the buzzer on and off, simply set a flag - have the interrupt routine check the flag before decrementing the counter.
 
Nigel Goodwin said:
rrb011270 said:
Mabuhay!

My buzzer routine below:
output_high(BUZZER);
delay_ms(200);
output_low(BUZZER);
delay_ms(450);

Is there another way such that I can use interrupt driven o reduce the instruction cycle of this routine?

My application is an RF reader which use an #int_ext2 to capture the ID from the badge. When it is successfull a buzzer will sound for success.

most of my code use the interrupt handler routine like the clock which use the #int_timer0 such it will capture the time and date and added to a complete packet of data which are compose of date, time, RFid, etc...

Any help will do?

Tenkyu

Assuming you have a timer interrupt running, simple decrement a counter on each interrupt call, when the counter reaches zero, toggle the output pin and reload the counter with the next value (you could use different values to give the assymetrical waveform you are currently using). To turn the buzzer on and off, simply set a flag - have the interrupt routine check the flag before decrementing the counter.

Can you u share a code snippet if any?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top