⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dianziqin.asm

📁 关于单片机的一系列的设计程序
💻 ASM
字号:
         Tone_h equ 30h
         Tone_l equ 31h
         Tone_num equ 100
         SPK   BIT  P0.7
         KEY   BIT  P3.4
         ORG 000H
         JMP MUSIC
         Org 001bh
         AJmp time1 
MUSIC:   MOV SP,#50H
         Mov tmod,#11h         ;16位定时器
         MOV A,#00H        
         SETB ET1
         SETB EA
key0:    MOV  P2,#0FFH
         CLR  KEY
         MOV  A,P2
Key1:    CJNE A,#01111111B,key2    ;KEY_SW1
         Mov tone_num,#00h
         Mov tone_h,#248
         Mov tone_l,#133
         MOV tl1,tone_l         
         Mov th1,tone_h
         Setb tr1                  ;启动定时器1
         Jmp end_k
Key2:    CJNE A,#10111111B,key3    ;KEY_SW2
         Mov tone_num,#00h
         Mov tone_h,#249
         Mov tone_l,#90
         MOV tl1,tone_l         
         Mov th1,tone_h
         Setb tr1                   ;启动定时器1
         Jmp end_k
Key3:    CJNE A,#11011111B,key4    ;KEY_SW3
         Mov tone_num,#00h
         Mov tone_h,#250
         Mov tone_l,#19
         MOV tl1,tone_l         
         Mov th1,tone_h
         Setb tr1                  ;启动定时器1
         Jmp end_k
Key4:    CJNE A,#11101111B,key5    ;KEY_SW4
         Mov tone_num,#00h
         Mov tone_h,#250
         Mov tone_l,#104
         MOV tl1,tone_l         
         Mov th1,tone_h
         Setb tr1            ;启动定时器1
         Jmp end_k
Key5:    CJNE A,#11110111B,key6    ;KEY_SW5
         Mov tone_num,#00h
         Mov tone_h,#251
         Mov tone_l,#04
         MOV tl1,tone_l         
         Mov th1,tone_h
         Setb tr1            ;启动定时器1
         Jmp end_k
Key6: CJNE A,#11111011B,end_k    ;KEY_SW6
         Mov tone_num,#00h
         Mov tone_h,#251
         Mov tone_l,#144
         MOV tl1,tone_l         
         Mov th1,tone_h
         Setb tr1            ;启动定时器1
      
End_k:  jmp   key0
;------------------------------------------------------------------
Time1: mov th1,tone_h
       Mov tl1,tone_l
       PUSH Acc                  ;定时1中断
       PUSH PSW
       PUSH DPH
       PUSH DPL
       Mov a,tone_num
       Inc acc
       Mov tone_num,a
       Cpl SPK
       Cjne a,#200,end_t1         ;发声100次
       Mov tone_num,#00h
       Clr tr1
End_t1: pop  dpl
        Pop dph
        Pop psw
        Pop acc
        reti 

 
            END       

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -