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

📄 zz-yjcut.asm

📁 pic资料
💻 ASM
📖 第 1 页 / 共 5 页
字号:
;              call        iic_save
              clrwdt
              movf        txdat10,0
              xorlw       .6
              btfss       status,2
              goto        sio_errbs

              movf        txdat12,0
	          xorlw       0e0h
              btfss       status,2
              goto        sio_errbs
              movf        txdat11,0
              xorlw       14h
              btfsc       status,2
              goto        sio_relay_off
              movf        txdat11,0
              xorlw       15h
              btfsc       status,2
              goto        sio_relay_on
              goto        sio_errbs
;**************************************
sio_relay_on
              bsf         flag,1 
              bcf         relay_led
              goto        $+3
sio_relay_off               
              bcf         flag,1
              bsf         relay_led

              movlw       i2c_code00
              movwf       iic_addr
              movlw       bcd1
              movwf       iic_back_addr
              movlw       04
              movwf       iic_count
              call        iic_read

              movf        bcd1,0
              xorwf       txdat13
              btfss       status,2 
              goto        sio_err_relay
              movf        bcd2,0
              xorwf       txdat14
              btfss       status,2
              goto        sio_err_relay
              movf        bcd3,0
              xorwf       txdat15
              btfss       status,2
              goto        sio_err_relay
              movf        bcd4,0
              xorwf       txdat16
              btfss       status,2
              goto        sio_err_relay
              
              bcf         relay_off
              bcf         relay_on 
              btfss       flag,1
              goto        $+3
              bsf         relay_on
              goto        $+2
              bsf         relay_off
              call        iic_save
 
              movlw       tmr1h_cons278
              movwf       tmr1h
              movlw       tmr1l_cons278
              movwf       tmr1l
              bsf         flag,2
              bsf         status,5
              clrf        relay_cnt1
              clrf        relay_cnt2
              bcf         status,5  
     clrf  rx_count
     bsf   intcon,7   ;intcon,6
     retlw     0
sio_relay_ret 
              btfss       flag,1 
              goto        offf
              btfsc       pdtest
              goto        sio_err_relay
              goto        sio_relay_ok             
offf
              btfss       pdtest
              goto        sio_err_relay
              goto        sio_relay_ok                      
sio_relay_ok
              movlw       081h
              movwf       txdat9
              movlw       05h
 	        movwf       txdat10
 	      
              movlw       21h
              movwf       txdat13
              movlw       4bh
              movwf       txdat14
              movlw       4fh
              movwf       txdat15
              bsf         status,5
              bsf         flag_display,1
              bcf         status,5  
              goto        sio_tx_loop
sio_err_relay
              movlw       0c1h
              movwf       txdat9
              movlw       05h
 	        movwf       txdat10 
              movlw       52h
              movwf       txdat13
              movwf       txdat14
              movlw       45h
              movwf       txdat15
              bsf         status,5
              bsf         flag_display,2
              bcf         status,5
              goto        sio_tx_loop 
;**************************************  
; 以下是编程,主站向从设备请求设置数据的程序段 
; 校验密码及相应的级别是否可以作此操作   
sio_write_data	   
	      movf        txdat13,0              ;judge code
              sublw       H'02'
              btfss       status,0
              goto        sio_erryq              ;越权操作            
               
	      call        code_check    
              btfsc       bzreg,4
              goto        right_mm 
	      call        code_super            
              btfss       bzreg,4
	      goto        sio_errmm               ;密码错误                         
right_mm	   
              bcf         bzreg,4
              movf        txdat12,0
	      xorlw       H'c0'
              btfsc       status,2
              goto        sio_write_refer0        ;修改表参数组0    
              movf        txdat12,0
              xorlw       H'c1'
              btfsc       status,2
              goto        sio_write_refer1        ;修改表参数组1  
              movf        txdat12,0
              xorlw       H'e4'
              btfsc       status,2
              goto        sio_write_zheng    
              goto        sio_errbs   
;-------------------------------------------
sio_write_refer0 
              movf        txdat11,0
              xorlw       H'30'
              btfsc       status,2
              goto        sio_write_constant       ;修改表常数
              movf        txdat11,0
              xorlw       H'32'
              btfsc       status,2
              goto        sio_write_bh             ;修改表号 
              goto        sio_errbs
;--------------------------------------------  
;修改表常数
sio_write_constant
                          btfss       portb,3
                          goto        sio_errff
			  movf        txdat18,0    ;txdat18前一位txdat17默认为0 
             		  movwf       metercons

			  movlw       0x01
			  movwf       iic_count
			  movlw       metercons
			  movwf       iic_back_addr
			  movlw       i2c_cons
			  movwf       iic_addr
             		  call        iic_write 
                          clrf        aen_plusnum
              		  goto        sio_write_tx 
;修改表号
sio_write_bh
           		  movlw       id1              
			  movwf       r1
             		  movlw       txdat17
			  btfsc       bzreg,3
             		  movlw       txdat11
			  movwf       r0
			  movlw       0x06
			  movwf       r2 
                          call        ram_copy
 
			  movlw       0x06
			  movwf       iic_count
			  movlw       id1
			  movwf       iic_back_addr
			  movlw       i2c_id1
			  movwf       iic_addr
			  call        iic_write 
              		  btfsc       bzreg,3
            		  goto        sio_changeid_board
             		  goto        sio_write_tx  
;--------------------------------------------- 
sio_write_refer1
              movf        txdat11,0
              xorlw       H'19'
              btfsc       status,2
              goto        sio_write_emstart       
              goto        sio_errbs
sio_write_emstart
              movlw       aen1_zong
	        movwf       r1
	        movlw       txdat17
	        movwf       r0
	        movlw       0x04
	        movwf       r2
	        call        ram_copy
    
              movlw       aen1_zong
              movwf       iic_back_addr
              movlw       i2c_aen1_zong
              movwf       iic_addr
              movlw       0x04
              movwf       iic_count 
              call        iic_write   
              clrf        aen_plusnum

              movlw       aen1_zong
              movwf       iic_back_addr
              movlw       i2c_cs_aen1
              movwf       iic_addr
              movlw       0x04
              movwf       iic_count 
              call        iic_write   
	      goto        sio_write_tx 
;---------------------------------------------
sio_write_zheng   
              movf        txdat11,0
              xorlw       H'11'
              btfsc       status,2
              goto        sio_write_ccbh     
              movf        txdat11,0
              xorlw       H'12'
              btfsc       status,2
              goto        sio_write_jbh         
              goto        sio_errbs
sio_write_ccbh
              movlw       txdat17
              movwf       iic_back_addr
              movlw       i2c_ccbh1
              movwf       iic_addr
              movlw       .5
              movwf       iic_count 
              call        iic_write   
              goto        sio_write_tx 
sio_write_jbh
              movlw       txdat17
              movwf       iic_back_addr
              movlw       i2c_jbh1
              movwf       iic_addr
              movlw       .12
              movwf       iic_count 
              call        iic_write   
              goto        sio_write_tx
;--------------------------------------------- 
sio_set_sbh       
              movf        txdat10,0
              xorlw       H'06'
              btfss       status,2
              goto        sio_over
              goto        sio_write_bh
sio_changeid_board
              movlw       id1              ;txdat11              
	      movwf       r0
	      movlw       txdat2           ;id1
	      movwf       r1
	      movlw       0x06
	      movwf       r2
 	      call        ram_copy

              movlw       0x00
              movwf       txdat10 
              goto        sio_tx 
;---------------------------------------------- 
sio_change_mima
              bcf         bzreg,4  
	      movf        txdat10,0
              xorlw       H'08'
              btfss       status,2
              goto        sio_zheng_mm
sio_gai_mm              
	      movf        txdat15,0
              movwf       temp1
              movf        txdat11,0
              subwf       temp1,0
              btfss       status,0
	      goto        sio_erryq 
                          
              call        code_check_y             
              btfsc       bzreg,4
              goto        rightmima
	       
              call        code_super 
              btfss       bzreg,4             	      
	      goto        sio_over            ;修改密码的时候,密码出错不应答 
rightmima                                       ;密码有效的程序段 
              bcf         bzreg,4
              movf        txdat15,0
              xorlw       H'00'
              btfsc       status,2
              goto        sio_chang_00          ;修改00级密码  
              movf        txdat15,0
              xorlw       H'01'
              btfsc       status,2
              goto        sio_chang_01          ;修改01级密码 
              movf        txdat15,0      
              xorlw       H'02'
              btfsc       status,2
              goto        sio_chang_02          ;修改02级密码  
              goto        sio_over 
sio_chang_00
              movlw       i2c_code00
              goto        sio_chang_mimaloop
sio_chang_01
              movlw       i2c_code01
              goto        sio_chang_mimaloop
sio_chang_02
              movlw       i2c_code02 
sio_chang_mimaloop  
	      movwf       iic_addr
              movlw       H'04'
              movwf       iic_count
              movlw       txdat15
              movwf       iic_back_addr 
	      call        iic_write 
;修改密码成功应答程序
sio_mimawrite_tx  
	      movf        txdat15,0
              xorlw       H'00'
              btfsc       status,2
              goto        sio_ans_00           ;应答修改的00级密码  
              movf        txdat15,0
              xorlw       H'01'
              btfsc       status,2
              goto        sio_ans_01           ;应答修改的01级密码         
	      movlw       i2c_code02           ;应答修改的02级密码
              goto        sio_ans_mima
sio_ans_00
	      movlw       i2c_code00
              goto        sio_ans_mima
sio_ans_01
	      movlw       i2c_code01
sio_ans_mima 
	      movwf       iic_addr
	      movlw       txdat11
	      movwf       iic_back_addr
	      movlw       0x04
	      movwf       iic_count 
              call        iic_read
              
              movlw       txdat10
              movwf       fsr
              movlw       0x04
              movwf       indf 
              goto        sio_tx  
;------------------------------------------------- 
sio_zheng_mm  
              movf        txdat10,0
              xorlw       H'06'
              btfss       status,2
              goto        sio_errbs
              movf        txdat16,0
              movwf       txdat18
              movf        txdat15,0
              movwf       txdat17
              movf        txdat14,0
              movwf       txdat16
              clrf        txdat15
              movf        txdat13,0
              movwf       txdat14
              movf        txdat12,0
              movwf       txdat13
              movf        txdat11,0
              movwf       txdat12
              clrf        txdat11              
              goto        sio_gai_mm
;*************************************************
sio_errcs
               movlw       H'11'            ;cs非法数据
              movwf       txdat11
              goto        sio_error
sio_errff 
	      movlw       H'01'            ;非法数据
              movwf       txdat11
              goto        sio_error
sio_errbs 
	      movlw       H'02'            ;数据标识错误
              movwf       txdat11
              goto        sio_error
sio_errmm
              movlw       H'04'
              movwf       txdat11
              goto        sio_error        ;密码错误
sio_erryq  
	      movlw       H'08'
              movwf       txdat11
        ;      goto        sio_error         ;越权操作
sio_error
              bsf         status,5
              bsf         flag_display,2
              bcf         flag_display,1
              bcf         status,5
              movf        txdat9,0
              addlw       H'0c0'
              movwf       txdat9           ;txdat9=c1

              movlw       H'01'            ;表明出错了!
              movwf       txdat10 
              goto        sio_tx_loop 
;--------------------------------------
;主站写数据时,从站正常应答程序
sio_write_tx 
              movlw       H'00'
              movwf       txdat10    
              goto        sio_tx      
;-------------------------------------- 
;485程序

⌨️ 快捷键说明

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