单片机唱歌---“祝你平安”(源码)

来源:本站
导读:目前正在解读《单片机唱歌---“祝你平安”(源码)》的相关信息,《单片机唱歌---“祝你平安”(源码)》是由用户自行发布的知识型内容!下面请观看由(电工技术网 - www.9ddd.net)用户发布《单片机唱歌---“祝你平安”(源码)》的详细说明。
简介:本文主要介绍了用单片机唱歌---“祝你平安”(源码)。

下面是他的asm源程序和hex程序(asm程序可以用配套光盘的uvw51e 编辑后得到hex,

当然下面的hex也可以直接复制到记事本后存为txt, 直接烧入芯片。注意XP套件支持文本烧写方式。 倚天版套件必须汇编。配套光盘里已经有汇编好的HEX,可以直接使用。 )

ORG 0000H

LJMP START

ORG 000BH

INC 20H ;中断服务,中断计数器加1

MOV TH0,#0D8H

MOV TL0,#0EFH ;12M晶振,形成10毫秒中断

RETI

START:

MOV SP,#50H

MOV TH0,#0D8H

MOV TL0,#0EFH

MOV TMOD,#01H

MOV IE,#82H

MUSIC0:

NOP

MOV DPTR,#DAT ;表头地址送DPTR

MOV 20H,#00H ;中断计数器清0

MOV B,#00H ;表序号清0

MUSIC1:

NOP

CLR A

MOVC A,@A+DPTR ;查表取代码

JZ END0 ;是00H,则结束

CJNE A,#0FFH,MUSIC5

LJMP MUSIC3

MUSIC5:

NOP

MOV R6,A

INC DPTR

MOV A,B

MOVC A,@A+DPTR ;取节拍代码送R7

MOV R7,A

SETB TR0 ;启动计数

MUSIC2:

NOP

CPL P3.3

MOV A,R6

MOV R3,A

LCALL DEL

MOV A,R7

CJNE A,20H,MUSIC2 ;中断计数器(20H)=R7否?

;不等,则继续循环

MOV 20H,#00H ;等于,则取下一代码

INC DPTR

; INC B

LJMP MUSIC1

MUSIC3:

NOP

CLR TR0 ;休止100毫秒

MOV R2,#0DH

MUSIC4:

NOP

MOV R3,#0FFH

LCALL DEL

DJNZ R2,MUSIC4

INC DPTR

LJMP MUSIC1

END0:

NOP

MOV R2,#64H ;歌曲结束,延时1秒后继续

MUSIC6:

MOV R3,#00H

LCALL DEL

DJNZ R2,MUSIC6

LJMP MUSIC0

DEL:

NOP

DEL3:

MOV R4,#02H

DEL4:

NOP

DJNZ R4,DEL4

NOP

DJNZ R3,DEL3

RET

NOP

DAT:

db 26h,20h,20h,20h,20h,20h,26h,10h,20h,10h,20h,80h,26h,20h,30h,20h

db 30h,20h,39h,10h,30h,10h,30h,80h,26h,20h,20h,20h,20h,20h,1ch,20h

db 20h,80h,2bh,20h,26h,20h,20h,20h,2bh,10h,26h,10h,2bh,80h,26h,20h

db 30h,20h,30h,20h,39h,10h,26h,10h,26h,60h,40h,10h,39h,10h,26h,20h

db 30h,20h,30h,20h,39h,10h,26h,10h,26h,80h,26h,20h,2bh,10h,2bh,10h

db 2bh,20h,30h,10h,39h,10h,26h,10h,2bh,10h,2bh,20h,2bh,40h,40h,20h

db 20h,10h,20h,10h,2bh,10h,26h,30h,30h,80h,18h,20h,18h,20h,26h,20h

db 20h,20h,20h,40h,26h,20h,2bh,20h,30h,20h,30h,20h,1ch,20h,20h,20h

db 20h,80h,1ch,20h,1ch,20h,1ch,20h,30h,20h,30h,60h,39h,10h,30h,10h

db 20h,20h,2bh,10h,26h,10h,2bh,10h,26h,10h,26h,10h,2bh,10h,2bh,80h

db 18h,20h,18h,20h,26h,20h,20h,20h,20h,60h,26h,10h,2bh,20h,30h,20h

db 30h,20h,1ch,20h,20h,20h,20h,80h,26h,20h,30h,10h,30h,10h,30h,20h

db 39h,20h,26h,10h,2bh,10h,2bh,20h,2bh,40h,40h,10h,40h,10h,20h,10h

db 20h,10h,2bh,10h,26h,30h,30h,80h,00H

END

以下是汇编通过的hex文件。

:03000000020014E7

:10000B000520758CD8758AEF32758150758CD87533

:10001B008AEF75890175A8820090007D75200075A7

:10002B00F00000E4936033B4FF0302005400FEA31E

:10003B00E5F093FFD28C00B2B3EEFB120072EFB57A

:10004B0020F4752000A302002D00C28C7A0D007BDA

:10005B00FF120072DAF8A302002D007A647B001203

:10006B000072DAF9020023007C0200DCFD00DBF8F1

:10007B002200262020202020261020102080262041

:10008B0030203020391030103080262020202020C6

:10009B001C2020802B20262020202B1026102B808C

:1000AB0026203020302039102610266040103910C1

:1000BB0026203020302039102610268026202B10A9

:1000CB002B102B203010391026102B102B202B40EF

:1000DB004020201020102B102630308018201820A4

:1000EB0026202020204026202B20302030201C20B2

:1000FB00202020801C201C201C2030203060391038

:10010B00301020202B1026102B10261026102B1011

:10011B002B801820182026202020206026102B2032

:10012B00302030201C202020208026203010301042

:10013B003020392026102B102B202B404010401044

:0B014B00201020102B10263030800008

:00000001FF

提醒:《单片机唱歌---“祝你平安”(源码)》最后刷新时间 2024-03-14 01:02:56,本站为公益型个人网站,仅供个人学习和记录信息,不进行任何商业性质的盈利。如果内容、图片资源失效或内容涉及侵权,请反馈至,我们会及时处理。本站只保证内容的可读性,无法保证真实性,《单片机唱歌---“祝你平安”(源码)》该内容的真实性请自行鉴别。