Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/24/03 11:08
Read: times


 
#42159 - RE: Produce a sound in moving coil speaker
Responding to: ???'s previous message
You think that Hardware is not a problem!!

Sorry. Dont connect speakers, solenoids, lamps, motors etc DIRECTLY to MCU port pins -whether you exceed the pin's current limit or not. Play it safe and use a transistor or other buffer in between. Dont ask me how - this topic has been discussed so much and so often in this forum. Search and you will find it within this site.

OK assuming you have got the buffer in place try out this code that will produce a nice beep ( 89c52 with a 12Mhz crystal ).

; beep on P1.7;
BEEP: MOV R7,#0
LCALL BEEPL1
MOV R7,#0
LCALL BEEPL2
SJMP BEEP
;
BEEPL1: SETB P1.7
LCALL BEEPT1
CLR P1.7
LCALL BEEPT1
DJNZ R7,BEEPL1
RET

BEEPL2: LCALL BEEPT1
LCALL BEEPT1
DJNZ R7,BEEPL2
RET

BEEPT1: MOV R6,#0
BEEPT2: DJNZ R6,BEEPT2
RET

Happy beeping...

Raghu

List of 6 messages in thread
TopicAuthorDate
Produce a sound in moving coil speaker            01/01/70 00:00      
   RE: Produce a sound in moving coil speaker            01/01/70 00:00      
   RE: Produce a sound in moving coil speak            01/01/70 00:00      
   RE: Produce a sound in moving coil speaker            01/01/70 00:00      
   RE: Produce a sound in moving coil speaker            01/01/70 00:00      
      RE: Produce a sound in moving coil speaker            01/01/70 00:00      

Back to Subject List