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.

Beep buzzer twice

Status
Not open for further replies.

adrianvon

Member
Hi all,

I connected a buzzer to a PIC microcontroller. Now i want to make it beep for approx 3sec, stop for 3 sec and then beep again for 3sec.

Now my problem is that when i decrement three registers, the buzzer is beeping for approx 12sec and when i decrement two registers the buzzer is beeping for approx 0.1sec. How can i make it beep for approx 3 sec??

Below is the coding that i am using:

BUZZER_UP
CLRF REG2
CLRF REG3
CLRF REG4
BSF PORTC,2
LINE1_BUZZER_UP
DECFSZ REG2
BRA LINE1_BUZZER_UP
DECFSZ REG3
BRA LINE1_BUZZER_UP
DECFSZ REG4
BRA LINE1_BUZZER_UP
BCF PORTC,2
CLRF REG2
CLRF REG3
CLRF REG4
LINE2_BUZZER_UP
DECFSZ REG2
BRA LINE2_BUZZER_UP
DECFSZ REG3
BRA LINE2_BUZZER_UP
DECFSZ REG4
BRA LINE2_BUZZER_UP
BSF PORTC,2
CLRF REG2
CLRF REG3
CLRF REG4
LINE3_BUZZER_UP
DECFSZ REG2
BRA LINE3_BUZZER_UP
DECFSZ REG3
BRA LINE3_BUZZER_UP
DECFSZ REG4
BRA LINE3_BUZZER_UP
BCF PORTC,2
GOTO LINE1_LOW_TEMP

Thanks is advance.
 
Instead of clearing the registers, place values in them.

If you reduce reg4 to a 1/4 of what it is (64 for an 8-bit PIC; 16384 for a 16-bit PIC), you will get a quarter of your current delay.

So replace 'CLRF REG4' with:

MOVLW 16384
MOVWF REG4

and that should give you a quarter of your current delay.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top