final_1.asm

来自「串口通信 频率测量 EEPROM读写程序」· 汇编 代码 · 共 659 行 · 第 1/2 页

ASM
659
字号
             rcall delay
             rcall turn_off
             ;-------------------display PC.3 second byte of time value
              rcall b4_d0   
              ret
            ;-------------------- ; PC.4 display "0" 
time_240: cpi r26,4
             brne time_270 
            ;----------------------
             ldi  r20,$5b                 
             out SPDR , r20 
             ldi r17,0b0000100  ; display byte PC.2 
             out PORTC,r17       
             rcall delay
             rcall turn_off
            ; ---------------------display PC.2 first byte of time value          
             ldi r20 ,$66       
             out SPDR , r20 
             ldi r17,0b00001000  ; display byte PC.3 
             out PORTC,r17       
             rcall delay
             rcall turn_off
             ;-------------------display PC.3 second byte of time value
              rcall b4_d0   
              ret
            ;-------------------- ; PC.4 display "0"  
time_270: cpi r26,5
             brne time_300 
            ;----------------------
             ldi  r20,$5b                 
             out SPDR , r20 
             ldi r17,0b0000100  ; display byte PC.2 
             out PORTC,r17       
             rcall delay
             rcall turn_off
            ; --------------------display PC.2 first byte of time value          
             ldi r20 ,$07       
             out SPDR , r20 
             ldi r17,0b00001000  ; display byte PC.3 
             out PORTC,r17       
             rcall delay
             rcall turn_off
             ;-------------------display PC.3 second byte of time value
              rcall b4_d0   
              ret
            ;-------------------- ; PC.4 display "0" 
time_300: cpi r26,6
             brne time_330 
            ;----------------------
             ldi  r20,$4f                
             out SPDR , r20 
             ldi r17,0b0000100  ; display byte PC.2 
             out PORTC,r17       
             rcall delay
             rcall turn_off
            ; --------------------display PC.2 first byte of time value          
             ldi r20 ,$3f       
             out SPDR , r20 
             ldi r17,0b00001000  ; display byte PC.3 
             out PORTC,r17       
             rcall delay
             rcall turn_off
             ;-------------------display PC.3 second byte of time value
              rcall b4_d0   
              ret
            ;-------------------- ; PC.4 display "0" 
time_330: cpi r26,7
             brne time_360 
            ;----------------------
             ldi  r20,$4f                
             out SPDR , r20 
             ldi r17,0b0000100  ; display byte PC.2 
             out PORTC,r17       
             rcall delay
             rcall turn_off
            ; --------------------display PC.2 first byte of time value          
             ldi r20 ,$4f       
             out SPDR , r20 
             ldi r17,0b00001000  ; display byte PC.3 
             out PORTC,r17       
             rcall delay
             rcall turn_off
             ;-------------------display PC.3 second byte of time value
              rcall b4_d0   
              ret
            ;-------------------- ; PC.4 display "0 
time_360: cpi r26,8
             brne time_390 
            ;----------------------
             ldi  r20,$4f                
             out SPDR , r20 
             ldi r17,0b0000100  ; display byte PC.2 
             out PORTC,r17       
             rcall delay
             rcall turn_off
            ; --------------------display PC.2 first byte of time value          
             ldi r20 ,$7d       
             out SPDR , r20 
             ldi r17,0b00001000  ; display byte PC.3 
             out PORTC,r17       
             rcall delay
             rcall turn_off
             ;-------------------display PC.3 second byte of time value
              rcall b4_d0   
              ret
            ;-------------------- ; PC.4 display "0  
time_390: cpi r26,9
             brne time_420 
            ;----------------------
             ldi  r20,$4f                
             out SPDR , r20 
             ldi r17,0b0000100  ; display byte PC.2 
             out PORTC,r17       
             rcall delay
             rcall turn_off
            ; --------------------display PC.2 first byte of time value          
             ldi r20 ,$6f       
             out SPDR , r20 
             ldi r17,0b00001000  ; display byte PC.3 
             out PORTC,r17       
             rcall delay
             rcall turn_off
             ;-------------------display PC.3 second byte of time value
              rcall b4_d0   
              ret
            ;-------------------- ; PC.4 display "0   
time_420: cpi r26,10
             brne time_450 
            ;----------------------
             ldi  r20,$66                
             out SPDR , r20 
             ldi r17,0b0000100  ; display byte PC.2 
             out PORTC,r17       
             rcall delay
             rcall turn_off
            ; --------------------display PC.2 first byte of time value          
             ldi r20 ,$5b       
             out SPDR , r20 
             ldi r17,0b00001000  ; display byte PC.3 
             out PORTC,r17       
             rcall delay
             rcall turn_off
             ;-------------------display PC.3 second byte of time value
              rcall b4_d0   
              ret
            ;-------------------- ; PC.4 display "0 
time_450: cpi r26,11
             brne time_480 
            ;----------------------
             ldi  r20,$66                
             out SPDR , r20 
             ldi r17,0b0000100  ; display byte PC.2 
             out PORTC,r17       
             rcall delay
             rcall turn_off
            ; --------------------display PC.2 first byte of time value          
             ldi r20 ,$6d       
             out SPDR , r20 
             ldi r17,0b00001000  ; display byte PC.3 
             out PORTC,r17       
             rcall delay
             rcall turn_off
             ;-------------------display PC.3 second byte of time value
              rcall b4_d0   
              ret
            ;-------------------- ; PC.4 display "0  
time_480:   nop
            ;----------------------
             ldi  r20,$66                
             out SPDR , r20 
             ldi r17,0b0000100  ; display byte PC.2 
             out PORTC,r17       
             rcall delay
             rcall turn_off
            ; --------------------display PC.2 first byte of time value          
             ldi r20 ,$7f       
             out SPDR , r20 
             ldi r17,0b00001000  ; display byte PC.3 
             out PORTC,r17       
             rcall delay
             rcall turn_off
             ;-------------------display PC.3 second byte of time value
              rcall b4_d0   
              ret
            ;-------------------- ; PC.4 display "0                                                                      
    b4_d0:  ldi  r20,$3f        
             out SPDR , r20 
             ldi r17,0b00010000        
             out PORTC,r17 
             rcall delay
             rcall turn_off                                      
             ret 
 turn_off: ser r16
           out DDRC,r16
           ldi r17,0b0000000
           out PORTC,r17  
           ret        
;------------------------------------------------------                   
 m_leddisp:  rcall flash_ram
             rcall turn_off 
             ldi r17,$05
             add r27,r17
             mov r20,r27 ;rcall flash_ram             
             ldi YL,$60           
             ldi YH,$00                   
             add YL,r20          ; r20 is content of display word
             ld  r20,Y           ;PC.0 display magnetic field trength      
             out SPDR , r20 
             ldi r17,0b00000001  ; display byte PC.0 
             out PORTC,r17       ;PC.0 output 1 ,
             rcall delay
             rcall turn_off
             ldi  r20,$3f        ; PC.1 display "0"
             out SPDR , r20 
             ldi r17,0b00000010        
             out PORTC,r17 
             rcall delay
             rcall turn_off              
             subi r27,$05
             ret  
flash_ram: ldi YL,$60           
           ldi YH,$00              ;RAM begin address
           ldi ZL ,low(seg_code*2) ; load Z register low byte
           ldi ZH ,high(seg_code*2); load Z register high byte
           ldi r18,$10             ;flash data block size
load_flash:lpm
           st Y+,r0
           adiw ZL,1
           dec r18
           brne load_flash
           ret
           .org $03f0           
  seg_code:.db $3f,$06,$5b,$4f,$66,$6d,$7d,$07
           .db $7f,$6f,$77,$7c,$39,$5e,$79,$71                                                                                  
 pwm_output: ret
 time_over: ldi r17,$02
            out TIMSK,r17;enable timer0 overflow   
      to:    cpi r26,-3
             brne tim60
             ldi r25,1
             rjmp time_end
       tim60:cpi r26,-2
             brne tim90
             ldi r25,2
             rjmp time_end
       tim90:cpi r26,-1
             brne tim120
             ldi r25,3
             rjmp time_end
      tim120:cpi r26,0
             brne tim150
             ldi r25,4
             rjmp time_end
      tim150:cpi r26,1
             brne tim180
             ldi r25,5
             rjmp time_end
      tim180:cpi r26,2
             brne tim210
             ldi r25,6
             rjmp time_end
      tim210:cpi r26,3
             brne tim240
             ldi r25,7
             rjmp time_end
      tim240:cpi r26,4
             brne tim270
             ldi r25,8
             rjmp time_end
      tim270:cpi r26,5
             brne tim300
             ldi r25,9
             rjmp time_end 
      tim300:cpi r26,6
             brne tim330
             ldi r25,10
             rjmp time_end   
      tim330:cpi r26,7
             brne tim360
             ldi r25,11
             rjmp time_end   
      tim360:cpi r26,8
             brne tim390
             ldi r25,12
             rjmp time_end   
      tim390:cpi r26,9
             brne tim420
             ldi r25,13
             rjmp time_end 
      tim420:cpi r26,10
             brne tim450
             ldi r25,14
             rjmp time_end 
      tim450:cpi r26,11
             brne tim480
             ldi r25,15
             rjmp time_end  
      tim480:cpi r26,12
             brne to
             ldi r25,16            
 time_end:   rcall thirty_minute
             dec r25
             breq end
             rjmp time_end
;----------------------------------------------------------------
 end:      ser r16
           out DDRC,r16 ;portc is output mode and turn off all LEDS
           clr r17
           out PORTC,r17 
;------------------------------------------------------------------
 timer0: inc r20
           reti
 thirty_minute:ldi r17,$00
           out TCNT0,r17;timer0  up count FF  
           ldi r17,$05
           out TCCR0,r17;CK/1024 and star counting         
           clr r20
           clr r21
    disp:  wdr                       
           cpi r20,255 ; if timer0 overflow shut down display                      
           breq again
           rjmp disp
    again: inc r21
           cpi r21,1    
           breq return
           clr r20
           rjmp disp
   return: ret     

⌨️ 快捷键说明

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