中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 單片機打鈴器設計

        單片機打鈴器設計

        作者: 時間:2013-03-12 來源:網絡 收藏


        fycz: dec r23
        brne gzcsxs1
        rcall EERead
        cpi r16,0
        brne fycz1
        inc r22
        cpi r22,4
        brmi fycz2
        clr r22
        fycz1: inc r25
        cpi r25,32
        brmi fycz2
        clr r25
        fycz2: rjmp gncs

        bzcz: dec r24
        brne gzcsxs1
        cpi r22,0
        brne bzcz2
        bzcz1: rcall EERead
        cpi r16,0
        breq bzcz11
        clr r16
        rjmp bzcz12
        bzcz11: ldi r16,1
        bzcz12: rcall EEWrite
        rjmp gncs
        bzcz2: add r17,r22
        rcall EERead
        inc r16
        cpi r22,1
        breq bzcz21
        cpi r16,60
        brmi bzcz22
        clr r16
        rjmp bzcz22
        bzcz21: cpi r16,24
        brmi bzcz22
        clr r16
        bzcz22: rcall EEWrite
        sub r17,r22
        rjmp gncs

        ;****顯示子程序************************************************
        ;*
        ;* 功能:將SRAM顯示緩沖區(qū)存放的數送數碼管顯示
        ;* 入口:DISBUF---顯示緩沖區(qū)起始地址(SRAM)
        ;* Y--顯示緩沖區(qū)的指針
        ;* DISTBL---顯示字符編碼表起始地址(FLASH)
        ;* LEDSXW---LED閃顯寄存器位設置
        ;* XSDBZ----小數點設置
        ;* 出口:Y--顯示緩沖區(qū)的指針,指向高地址
        ;*
        ;****程序段
        display: nop
        push temp
        push temp1
        push temp2
        push temp3
        push temp4
        push r6
        ldi temp1,6
        ldi temp3,0b11011111
        ldi yl,low(DISBUF)
        ldi yh,high(DISBUF)
        ldi xl,low(XSDBZ)
        clr xh
        ld r6,x
        disp1: ld temp,y+
        ldi zl,low(DISTBL)
        ldi zh,high(DISTBL)
        add zl,temp
        lsl zl
        rol zh
        lpm
        lsr r6
        brcc disp2
        ldi temp4,0b10000000
        or r0,temp4
        disp2: out PORTC,r0
        in temp2,PORTA
        ori temp2,0b00111111
        and temp2,temp3
        out PORTA,temp2
        sec
        ror temp3
        rcall delay
        in temp2,PORTA
        ori temp2,0b00111111
        out PORTA,temp2 ;關顯示
        dec temp1
        brne disp1
        pop r6
        pop temp4
        pop temp3
        pop temp2
        pop temp1
        pop temp
        ret

        ;****時鐘顯示子程序************************************************
        colodis: push temp
        ldi yl,low(DISBUF) ;設置顯示緩沖區(qū)起始地址
        clr yh
        ldi xl,low(TIMEDIS) ;設置時鐘時分秒存放單元
        clr xh
        ldi zl,low(XSDBZ)
        clr zh
        ldi temp,0b00001010 ;b0-5對應LED自左到右1-6位的小數點,置“1”在該位置小數點。
        st z,temp
        rcall ram6ram
        rcall display
        pop temp
        ret

        ;****延時子程序**************************************************

        delay: nop ;延時子程序
        push temp2
        push temp1
        ldi temp2,$ff
        lp1: ldi temp1,$f
        lp2: dec temp1
        brne lp2
        dec temp2
        brne lp1
        pop temp1
        pop temp2
        ret ;子程序返回

        ;****寫EEPRON子程序************************************************
        ;*
        ;*功能:將EEDWR(r16)內容寫入以EEAWR(r18:r17)內容為地址的EEPRON單元內。
        ;*
        ;****程序段
        EEWrite:sbic EECR,EEWE
        rjmp EEWrite
        out EEARH,EEawrh
        out EEARL,EEawr
        out EEDR,EEdwr
        sbi EECR,EEMWE
        sbi EECR,EEWE
        ret

        ;****讀EEPRON子程序*************************************
        ;*
        ;*功能:從以EEARD(r18:r17)內容為地址的EEPRON單元讀區(qū)內容送EEDRD(r16)寄存器。
        ;*
        ;****程序段
        EERead: sbic EECR,EEWE
        rjmp EERead
        out EEARH,EEardh
        out EEARL,EEard
        sbi EECR,EERE
        sbi EECR,EERE
        in EEdrd,EEDR
        ret

        ;****6字節(jié)SRAM內容傳送子程序************************************************************
        ;*
        ;* 功能:將SRAM內連續(xù)6字節(jié)由BLOCK1傳送到BLOCK2
        ;* x---欲傳送6字節(jié)起始地址(SRAM)指針
        ;* y---欲放置6字節(jié)起始地址(SRAM)指針
        ;*
        ;****程序段
        ram6ram:push temp1
        push temp2
        ldi temp1,$06
        ramd1: ld temp2,x+
        st y+,temp2
        dec temp1
        brne ramd1
        pop temp2
        pop temp1
        ret

        ;****8位二進制數轉3位BCD數子程序********************************************************
        ;*
        ;*功能:把一個8位無符號二進制數轉換為3位BCD碼數。
        ;*入口:r16---內裝8位無符號二進制數。
        ;*出口:BCD碼放在r2:r3:r4,r2存放百位。
        ;*
        ;****程序段

        bt push r16
        clr r2
        clr r3
        clr r4
        rjmp bto2
        bto1: inc r2
        bto2: subi r16,100
        brpl bto1
        ldi temp,100
        add r16,temp
        rjmp bto4
        bto3: inc r3
        bto4: subi r16,10
        brpl bto3
        ldi temp,10
        add r16,temp
        mov r4,r16
        pop r16
        ret
        ;****時鐘0中斷服務程序******************************************************

        .org $0bf0
        TIM0_OVF: push temp
        ldi temp,256-195
        out tcnt0,temp ;重裝T0時間常數
        inc cntms
        mov temp,cntms
        cpi temp,40
        brne timecunt
        clr cntms
        inc second
        mov temp,second
        cpi temp,60
        brne timecunt
        clr second
        ldi TIM0INT,1
        inc minute
        mov temp,minute
        cpi temp,60
        brne timecunt
        clr minute
        inc hour
        mov temp,hour
        cpi temp,24
        brne timecunt
        clr hour
        timecunt: ldi xl, low(TIMEDIS)
        clr xh
        mov r16,hour
        rcall bto
        st x+,r3
        st x+,r4
        mov r16,minute
        rcall bto
        st x+,r3
        st x+,r4
        mov r16,second
        rcall bto
        st x+,r3
        st x+,r4
        pop temp
        reti

        ;****字形表**********************************************
        .cseg
        .org DISTBL
        .dw 0x003f,0x0006,0x005b,0x004f,0x0066,0x006d,0x007d,0x0007,0x007f,0x006f
        .dw 0x0077,0x007c,0x0039,0x005e,0x0079,0x0071,0x0073,0x0076,0x0058,0x0038
        .dw 0x005c,0x0067,0x0050,0x006e,0x0078,0x0000,0x0054,0x0040,0x0074,0x0000


        上一頁 1 2 3 下一頁

        關鍵詞: 單片機 打鈴器 AT90S8515

        評論


        相關推薦

        技術專區(qū)

        關閉