Hello, everybody.
I develop an OS with my friends and I want to know how program a internal buzzer driver.
We want to can play melody with the internal buzzer and to make it, we want to change the buzzer frequency for example.
Where can I have some information?
Thanks.
buzzer programming?
Re:buzzer programming?
Code: Select all
org 100h
xor ah,ah
int 16h
call Beep1
xor ah,ah
int 16h
call Beep2
xor ah,ah
int 16h
ret
Beep1:
MOV [Hz],100h
CALL Sound
CALL DeLay
CALL NOSOUND
RET
;------------------------------------------------------------------------------------------------
; Beep tone 2
;------------------------------------------------------------------------------------------------
Beep2:
MOV [Hz],150h
CALL Sound
CALL DeLay
CALL NOSOUND
RET
;------------------------------------------------------------------------------------------------
; Sound
;------------------------------------------------------------------------------------------------
Sound:
MOV BX,[Hz] ;This
MOV AX,34DDH
MOV DX,0012H
CMP DX,BX
JNC DONE1
DIV BX
MOV BX,AX
IN AL,61H
TEST AL,3
JNZ A99
OR AL,3
OUT 61H,AL
MOV AL,0B6H
OUT 43H,AL
A99:
MOV AL,BL
OUT 42H,AL
MOV AL,BH
OUT 42H,AL
DONE1:
RET
;------------------------------------------------------------------------------------------------
; Delays
;------------------------------------------------------------------------------------------------
DeLay:
MOV CX, [MilliS]
JCXZ A2
A1:
CALL DeLaYoneMS
LOOP A1
A2: RET
;------------------------------------------------------------------------------------------------
;Delay
;------------------------------------------------------------------------------------------------
DeLaYoneMS:
PUSH CX ; Save CX
MOV CX, [OneMS] ; Loop count into CX
B1:
LOOP B1 ; Wait one millisecond
POP CX ; Restore CX
RET
;------------------------------------------------------------------------------------------------
; Turn sound off
;------------------------------------------------------------------------------------------------
NOSOUND:
IN AL,61h
AND AL,11111100b
OUT 61h,AL
RET
Hz DW ?
MilliS DW 200
OneMS DW 40000
\\\\||////
(@@)
ASHLEY4.
Batteries not included, Some assembly required.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:buzzer programming?
more theorically, the "buzzer" is usually called "internal PC speaker". It's a trick IBM set up from a free clock generator (8253) and a free output bit on the multi-purpose parallel interface (8255, now emulated on the 8042)
Re:buzzer programming?
does anyone now why i can hardly hear the internal pc speaker on new computers while my 286/386:es can be heard from a diffrent room?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:buzzer programming?
probably because nowadays
- PC speakers are emulated on the soundcard speaker, rather than being a separated device
- the wave is thus no longer a Square (one of the more loud soundwaves) but something smoother
- noone really wish to hear the neighbour's PC speaker
- PC speakers are emulated on the soundcard speaker, rather than being a separated device
- the wave is thus no longer a Square (one of the more loud soundwaves) but something smoother
- noone really wish to hear the neighbour's PC speaker
Re:buzzer programming?
Maybe i do..- noone really wish to hear the neighbour's PC speaker