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

📄 avr3k5k-21p.asm

📁 数码管显示接继电器式交流稳压器
💻 ASM
📖 第 1 页 / 共 3 页
字号:
        
           MOV      TEMP11,A
           MOVAM    TEMP4
           MOV      TEMP12,A
           MOVAM    TEMP5
           LCALL    hex2dec
           lcall    con_disp_code
           
           ret
           ;=======================
display_unusual:
           btsc     flash
           lgoto    flsh_clr
           bs       flash
           lgoto    next_unusual
flsh_clr:  
           bc       flash  
            
next_unusual:         
           btsc     flash
           lgoto    off_dig_led
        
           btsc     temp_status
           lgoto    disp_temp_high
               
           btsc     sys_status0
           lgoto    disp_L
           ;-----disp High
           bs       bled0
           bc       bled1
           bs       bled2
           mov      Vin_L,a
           MOVAM    temp5
           mov      Vin_H,a
           movam    temp4
           LCALL    hex2dec
           mov      temp1,a
           movam    temp8
           mov      temp2,a
           movam    temp9
           mov      temp3,a
           movam    temp10
           movla    .12   
           movam    temp1;dig1 off
           movam    temp3;dig3 off
           movla    .10
           movam    temp2;dig2 H
           ;---------
           ;mov      Vout_L,A
           ;MOVAM    temp5
           ;mov      Vout_H,A
           ;movam    temp4
           ;LCALL    hex2dec
           ;---------
           lcall    con_disp_code
           ret
disp_L: 
           bs       bled0
           bc       bled1
           bs       bled2
           mov      Vin_L,a
           MOVAM    temp5
           mov      Vin_H,A
           movam    temp4
           LCALL    hex2dec
           mov      temp1,a
           movam    temp8
           mov      temp2,a
           movam    temp9
           mov      temp3,a
           movam    temp10
           movla    .12
           movam    temp1;dig1 off
           movam    temp3;dig3 off
           movla    .11
           movam    temp2;dig2 L
           ;---------
           ;mov      Vout_L,A
           ;MOVAM    temp5
           ;mov      Vout_H,A
           ;movam    temp4
           ;LCALL    hex2dec
           ;---------
           lcall    con_disp_code        
           ret        
disp_temp_high:
           bs       bled0
           bc       bled1
           bs       bled2
           mov      Vin_L,a
           MOVAM    temp5
           mov      Vin_H,a
           movam    temp4
           LCALL    hex2dec
           mov      temp1,A
           movam    temp8
           mov      temp2,a
           movam    temp9
           mov      temp3,a
           movam    temp10
           movla    .14
           movam    temp1;dig1 c
           movla    .12   
           movam    temp2;dig2 off
           movla    .10
           movam    temp3;dig3 H
           lcall    con_disp_code
           ret
off_dig_led:        
           bs       bled0
           bc       bled1
           bc       bled2
           movla    .12   
           movam    temp8
           movam    temp9
           movam    temp10
           movam    temp1;dig1 off
           movam    temp2;dig2 off
           movam    temp3;dig3 off
           lcall    con_disp_code
           ret

;===========================================
hex2dec:
;------TEMP4,TEMP5 is the value should be converted
	   clr      TEMP1
	   clr      TEMP2
	   clr      TEMP3
hex2dec_init:
           MOV      TEMP5,A
           MOVAM    TEMP7                  
	   movla    .100
	   sub      temp5,m
	   BTSS     STATUS,C
	   LGOTO    _step100
	   INC      TEMP1,M
	   LGOTO    hex2dec_init
_step100:
           mov      temp4,a
           btsc     STATUS,Z
           lgoto    next_step
           dec      temp4,m
           inc      temp1,m
           inc      temp1,m
           movla    .56
           add      temp7,a
           movam    temp5
           lgoto    hex2dec_init

next_step:
	   mov      temp7,a	   
	   movam    TEMP5
	   movla    .10
	   sub      temp7,m
	   btss     STATUS,C
	   lgoto    second_step
	   inc      temp2,m
	   lgoto    next_step
second_step:
	   mov      temp5,a
	   movam    temp3
	   ret
;==========================================
con_disp_code:
           MOVLA    07H
           movam    tab_bnk
           tabrdl   temp8
           movam    temp8
           
           MOVLA    07H
           movam    tab_bnk
           tabrdl   temp9
           movam    temp9

           MOVLA    07H
           movam    tab_bnk
           tabrdl   temp10
           movam    temp10

	   MOVLA    07H
           movam    tab_bnk
           tabrdl   temp1
           movam    temp1
	   btsc     bled0
	   bc       temp1,7
	   
	   MOVLA    07H
           movam    tab_bnk
           tabrdl   temp2
           movam    temp2
	   btsc     bled1
	   bc       temp2,7
	   
	   MOVLA    07H
           movam    tab_bnk
           tabrdl   temp3
           movam    temp3
	   btsc     bled2
	   bc       temp3,7
	
	   BC       IRQM,INTM
	   
	   mov      temp8,a
	   movam    disp_buf0
	   mov      temp9,a
	   movam    disp_buf1
	   mov      temp10,a
	   movam    disp_buf2
	   mov      temp1,a
	   movam    disp_buf3
	   mov      temp2,a
	   movam    disp_buf4
	   mov      temp3,a
	   movam    disp_buf5
	
	   BS       IRQM,INTM

	   ret
;===========================================
sample_INvol:
           clr      temp0
           clr      temp1
           clr      temp2;total samples times
           clr      temp3
           clr      temp4
           clr      temp6
           movla    MAX_SAMPLE_TIME
           movam    SAMPLETIME
           ;=============
sample_loop0:
           
           NOP
           MOVLA    00H
           MOVAM    AD_CTL1
           MOVLA    02H;01H
           MOVAM    AD_CTL2
           MOVLA    03H
           MOVAM    AD_CTL3
           NOP
           NOP
           BTSC     AD_CTL1,7
           LGOTO    $-1
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           nop
               ;BS     _RL1
           nop
           nop
           BS       AD_CTL1,7
           BC       IRQF,6
           NOP
           NOP
           BTSS     IRQF,6
           LGOTO    $-1
           BC       IRQF,6
           NOP
           NOP
           MOV	    AD_DAT,A
           MOVAM    temp1
           movam    temp0
           ;====================== 
               ;BC     _RL1        
           ;======================           
           MOVLA    .99
           SUB      temp1,m
           btss     STATUS,C
           lgoto    _smaller99
add_sumin:
           mov      temp1,a           
           add      temp4,m
           clra
           addc     temp3,m
           
           inc      temp2,m
           ;---------------
           tmsc     SAMPLETIME
           ;---------------           
           lgoto    sample_loop0
           lcall    caculate_vol           
           ret
           
_smaller99:
           movla    .99
           movam    temp1
           mov      temp0,a
           sub      temp1,m
           lgoto    add_sumin
;===========================================
sample_OUTvol:
           clr      temp0
           clr      temp1
           clr      temp2;total samples times
           clr      temp3
           clr      temp4
           clr      temp6
           movla    MAX_SAMPLE_TIME
           movam    SAMPLETIME
           ;=============
sampleOUT_loop0:
           
           NOP
           MOVLA    01H
           MOVAM    AD_CTL1
           MOVLA    02H;01H
           MOVAM    AD_CTL2
           MOVLA    03H
           MOVAM    AD_CTL3
           NOP
           NOP
           BTSC     AD_CTL1,7
           LGOTO    $-1
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           NOP
           nop
               ;BS     _RL1
           nop
           nop
           BS       AD_CTL1,7
           BC       IRQF,6
           NOP
           NOP
           BTSS     IRQF,6
           LGOTO    $-1
           BC       IRQF,6
           NOP
           NOP
           MOV	    AD_DAT,A
           MOVAM    temp1
           movam    temp0
           ;====================== 
               ;BC     _RL1        
           ;======================           
           MOVLA    .99
           SUB      temp1,m
           btss     STATUS,C
           lgoto    temp1_smaller99
add_sum:
           mov      temp1,a           
           add      temp4,m
           clra
           addc     temp3,m
           
           inc      temp2,m
           ;---------------
           tmsc     SAMPLETIME
           ;---------------           
           lgoto    sampleOUT_loop0
           lcall    caculate_vol           
           ret
           
temp1_smaller99:
           movla    .99
           movam    temp1
           mov      temp0,a
           sub      temp1,m
           lgoto    add_sum
;===========================================
;temp3,temp4/temp2-->temp0,temp1
caculate_vol:           
                      
           clr      temp6
           clr      temp1
           clr      temp0
sub_loop:
           MOV      TEMP4,A
           MOVAM    TEMP7                  

	   MOV      temp2,a
	   
	   sub      temp4,m
	   BTSS     STATUS,C
	   LGOTO    sub_next1
	   INCSZ    TEMP1,M
	   LGOTO    sub_loop
	   INC      TEMP0,M
	   lgoto    sub_loop
sub_next1:
           mov      temp3,a
           btsc     STATUS,Z
           lgoto    sub_ret
           dec      temp3,m
           movla    .255
           movam    temp6
           inc      temp7,m
sub_loop0:
           mov      temp6,a
           movam    temp8
           mov      temp2,a
           sub      temp6,m
           btss     STATUS,C
           lgoto    sub_next2
           incsz    temp1,m
           lgoto    sub_loop0
           inc      temp0,m
           lgoto    sub_loop0
sub_next2:
           mov      temp8,a
           add      temp7,a
           movam    temp4
           clr      temp6
           lgoto    sub_loop
sub_ret: 
           bc       STATUS,C
           rlc      temp1,m
           rlc      temp0,m
           
           mov      temp1,a
           movam    temp6
           mov      temp0,a
           movam    temp5
           
           bc       STATUS,C
           rlc      temp1,m
           rlc      temp0,m
           
           mov      temp6,a
           add      temp1,m
           mov      temp5,a
           addc     temp0,m           
           ;========adjust the voltage           
           tmsc     temp0
           lgoto    adjust06
           ;movla    .150
           ;sub      temp1,a
           ;btss     STATUS,C
           ;ret           
           movla    .160
           sub      temp1,a
           btsc     STATUS,C
           lgoto    adjust00
           ;dec      temp1,m
           ret
adjust00:
           movla    .170
           sub      temp1,a
           btsc     STATUS,C
           lgoto    adjust01
           dec      temp1,m
           ;dec      temp1,m
           ret
adjust01:
           movla    .210
           sub      temp1,a
           btsc     STATUS,C
           lgoto    adjust02
           movla    .2
           sub      temp1,m
           ret
adjust02:
           movla    .220
           sub      temp1,a
           btsc     STATUS,C
           lgoto    adjust03
           movla    .3
           sub      temp1,m
           ret
adjust03:
           movla    .230
           sub      temp1,a
           btsc     STATUS,C
           lgoto    adjust04
           movla    .4
           sub      temp1,m
           ret
adjust04:
           ;movla    .240
           ;sub      temp1,a
           ;btsc     STATUS,C
           ;lgoto    adjust05
           ;movla    .6
           ;sub      temp1,m
           ;ret
adjust05:
           movla    .5
           sub      temp1,m
           ret
adjust06:
           dec      temp0,m
           movla    .251;249
           add      temp1,m
           clra
           addc     temp0,m

           ret
;===========================================
DELAY:
           NOP
           DECSZ   50H,M
           LGOTO   $-1
           DECSZ   51H,M
           LGOTO   $-3
           NOP
           RET
;===========================================
dbl_divs:
_divs_do:
           bc       STATUS,C
           rrc      temp0,m
           rrc      temp1,m
           
           decsz    temp2,m
           lgoto    _divs_do
              
           ret           
;===========================================
        ORG    700H
        dw     0c0h		;num 0
        DW     0f9h		;    1
        DW     0a4h		;    2
        DW     0b0h		;    3
        DW     99h		;    4
        DW     92h		;    5
        DW     82h		;    6
        DW     0d8h		;    7
        DW     80h		;    8	
        DW     90h		;    9
        DW     89h		;H   10
        DW     0c7h 	        ;L   11
        DW     0ffh		;clrx	   12
        DW     00H		;ALL LIGHT 13
        DW     0a7h             ;c         14
        
        END
;===========================================
;===========================================

⌨️ 快捷键说明

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