My Link

Photobucket

Rangkaian pembangkit Nada dengan mikrokontroller

Figure 1 Tone generating using microcontroller


Loud speaker is connedted to P0.0, in this program, there are two tone that will beep loud speaker.

$mod51

org 00h

jmp mulai

org 0bh

jmp hitung

hitung: cjne r5, #00h, maju

mov r5, #14

maju: dec r5

cjne r5, #00, exit

cjne r7, #50, maju2

mov r7, #00

maju2: inc r7

exit: reti

mulai: mov a, #00h

mov p0, #00h

mov p1, #00h

mov p3, #00h

mov r5, #20h

mov tmod, #81h

mov tcon, #00h

mov ie, #00h

setb ie.7

setb ie.1

setb tr0

loop: mov a, r7

jnb acc.0, nada1

acall beep2

nada1: acall beep

jmp loop

beep: mov r1, #150

ulang: dec r1 ;12 siklus

setb p0.0 ;12 siklus

cjne r1, #00h, ulang ; 24 siklus

mov r2, #150

ulang2: dec r2

clr p0.0 ; 12 siklus

cjne r2, #00h, ulang2

ret

beep2: mov r1, #200

ulang3: dec r1

setb p0.0

cjne r1, #00h, ulang3

mov r2, #200

ulang4: dec r2

clr p0.0

cjne r2, #00h, ulang4

ret

end

0 komentar: