返回主页 单片机教程XL2000开发板 单片机学习 自制编程器 单片机资料 软件下载 电子技术产品介绍如何购买 论坛

;***************************************************************************
;E-mail:sxj1974@163.com (51c51 test web)  51单片机学习网,自学单片机的网站    *
;* Create by :石学军 ;应天津网友张默要求编制的八音盒程序,适用于本站各版本开发套件。
;声音分十个频率逐渐提高, 修改频率和时长可实现不同的声音效果。 
;if the 32h&33h overflow,then p3.3 cpl.
;if the 30h&31h overflow,then update 32h&33h.
org 0000h
ajmp main
org 000bh
 ajmp timer0
org 0030h

timer0:
clr ea
djnz 33h,exit
mov 33h,53h
djnz 32h,exit
mov 32h,52h
djnz 31h,exit1
mov 31h,51h
djnz 30h,exit1
setb f0
ajmp exit
exit1: cpl p3.3
exit: setb ea
reti
main:
mov tmod,#02h
mov ie,#82h
mov th0,#254
mov tl0,#254
mov dptr,#tab
main1:
mov 40h,#00h
loop:
clr ea
mov a,40h
movc a,@a+dptr
mov 30h,a
mov 50h,a
inc 40h
mov a,40h
movc a,@a+dptr
mov 31h,a
mov 51h,a
inc 40h
mov a,40h
movc a,@a+dptr
mov 32h,a
mov 52h,a
inc 40h
mov a,40h
movc a,@a+dptr
mov 33h,a
mov 53h,a
setb ea
setb tr0
jnb f0,$
clr f0
inc 40h
mov a,40h
cjne a,#40,loop
ajmp main1
tab: ; 30h,31h,32h,33h
db 2,25,24,16 ;low frequency
db 4,25,24,8
db 8,25,24,4
db 12,25,12,4
db 20,25,6,4
db 30,25,5,4
db 40,25,4,4
db 50,25,3,4
db 60,25,2,4
db 70,50,1,4

end

hex格式文件下载(点右键,目标另存为hex即可直接烧写)