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

📄 zz-yjcut.asm

📁 pic资料
💻 ASM
📖 第 1 页 / 共 5 页
字号:
	     decfsz        r0
           goto          lcd_data100                                                                             
           retlw         0
write_lcd101 
         movlw         0a0h            ;write 101 and addres
         movwf         lcdtemp1
         movlw         03
         movwf         r0  
         call          lcd_data100 
         retlw         0 
write_addr
         movwf         lcdtemp1
         bcf           status,0
         rlf           lcdtemp1
         rlf           lcdtemp1 
         movlw         .6
         movwf         r0
lcd_addr
           bcf           status,0
           bcf           ht1621_wr       
	     rlf           lcdtemp1
	     btfsc         status,0
	     goto          $+3
	     bcf           ht1621_data 
	     goto          $+2
	     bsf           ht1621_data 
	     goto          $+1
           bsf           ht1621_wr
	     decfsz        r0
           goto          lcd_addr
           retlw         0
;------------------------------------
clrlcd   
         call          write_lcd101
         movlw         0
	   call          write_addr 
         movlw         .128
         movwf         r0
	   bcf           ht1621_wr   
         nop    
	   bcf           ht1621_data
         nop
         bsf           ht1621_wr
         decfsz        r0
         goto          $-6          
         return  
;------------------------------------
initlcd  
         clrwdt
         call          write_init
         bsf           ht1621_cs
xian
         goto          $+1
         bcf           ht1621_cs
         call          write_8888   
         call          delay1 
         call          delay1 
         bsf           ht1621_cs
         nop
	   bcf           ht1621_cs        
         call          clrlcd  
  ;       call          delay1
         bsf           ht1621_cs
         bsf           status,5
         clrf          display_cn1
         clrf          display_cn2
         clrf          flag_display
         bcf           status,5 
	 return 
write_init        
         movlw         lcdon
         movwf         bcd5
         movlw         sysen
         movwf         bcd6
         movlw         rc256
         movwf         bcd4
         movlw         bias3
         movwf         bcd3         
         call          write_lcd100 
         movlw         .4
	 movwf         r0
         movlw         bcd6
	 movwf         fsr   
write_lcdml    
             movf          indf,0
	     movwf         lcdtemp1 
	     movlw         .8
	     movwf         r2
lcd_data
	     bcf           status,0
             bcf           ht1621_wr
             rlf           lcdtemp1 
             btfss         status,0
             goto          $+3
             bsf           ht1621_data
             goto          $+2
             bcf           ht1621_data
	     nop
	     bsf           ht1621_wr
	     goto	   $+1
	     decfsz        r2
	     goto          lcd_data
             bcf           ht1621_wr
             bcf           ht1621_data 
	     bsf           ht1621_wr
	     decf          fsr
	     decfsz        r0
	     goto          write_lcdml
	     retlw         0   
;*************************************
write_8888 	 
             bcf          ht1621_cs
             call         write_lcd101
             movlw        .0
	     call         write_addr 
             movlw        .128
	     movwf        r0
             bcf          status,0
	     bcf          ht1621_wr
             nop	            
	     bsf          ht1621_data 
	     nop
             bsf          ht1621_wr		    
	     decfsz       r0
	     goto         $-6
             bsf          ht1621_cs
	     retlw        0  
;*************************************
code485	     
				clrwdt
				movf        rx_count,0
				btfss       status,2			
				goto        sio_rx_L 
				retlw       0 
;************************************* 
sio_rx_L                            
				movlw       0x20 
				subwf       rx_count,0
				btfsc       status,0
				goto        sio_over
				
				movlw       0x0b
				subwf       rx_count,0
				btfss       status,0
				retlw       0  
				movf        txdat10,0  
				addlw       d'12'       
				movwf       length                   	
				
				movf        length,0
				subwf       rx_count,0
				btfss       status,0
				retlw       0
				bsf         bzreg,2
				bcf         intcon,7  ;intcon,6			                           	  
;************************************  
sio_rx_judge    		
                        btfsc       rx_sta,6
				goto        sio_over     ;sio_errcs		
				bcf         bzreg,3 
				movf        txdat1,0
				sublw       H'68'
				btfss       status,2              
				goto        sio_over
				movf        txdat8,0
				sublw       H'68'
				btfss       status,2
				goto        sio_over
sio_rx_loop9						   ;判断设备号是不是广播地址99999999999999  
 
				bcf         bzreg,3    
				movlw       txdat2
				movwf       fsr
				movlw       H'6'
				movwf       r2
sio_rx_loop1	      
		        movf        indf,0
		        xorlw       0x99
		      btfss       status,2
	            goto        sio_rx_dat2
	            incf        fsr
		      decfsz      r2
		      goto        sio_rx_loop1
	            bsf         bzreg,3
	            goto        sio_rx_cscheck

;当设备号不是999999999999时!在判断设备号是不是和本表的设备号一致
sio_rx_dat2 
              movlw       H'6'
              movwf       r0
              movlw       txdat2
              movwf       r1
              movlw       id1
              movwf       r2
sio_rx_compid  
	        movf        r1,0  
              movwf       fsr
              movf        indf,0
              movwf       temp1                    ;compid id the received byte    
              movf        r2,0   
              movwf       fsr
              movf        indf,0
              xorwf       temp1,0
              btfss       status,2              
	        goto        sio_over                 ;设备号不对!!去出错处理程序!!!不应答
sio_rx_compid1
              incf        r1
              incf        r2
              decfsz      r0
              goto        sio_rx_compid   
sio_rx_cscheck
;接收到的数据作-33处理,得到标准数据 
              call        sio_cscheck              ;累加后放在W内!  
              xorwf       indf,0
              btfss       status,2
              goto        sio_errff                ;出错,执行非正常应答         
              incf        fsr
              movf        indf,0
              xorlw       H'16'
              btfss       status,2
              goto        sio_errff
              movf        txdat10,0                ;数据域没有数据的时候不用作减33运算
	        xorlw       0x00
	        btfsc       status,2
              goto        sio_rx_lop10 
sio_rx_sub33
              movf        txdat10,0
              movwf       r2
              movlw       txdat11
              movwf       fsr
sio_rx_sub
              movlw       0x33
              subwf       indf,1
              incf        fsr
              decfsz      r2
              goto        sio_rx_sub
sio_rx_lop10 
              btfsc       bzreg,3
              goto        sio_rx_99
              goto        sio_rx_contrl  
sio_rx_99
              bsf         bzreg,3              
	        movf        txdat9,0
	        xorlw       H'0a'
	        btfsc       status,2
	        goto        sio_set_sbh             ;广播写设备地址  
              goto        sio_over           
;*************************************** 
sio_rx_contrl
            movf        txdat9,0
	      xorlw       H'01'                 
	      btfsc       status,2
	      goto        sio_read_data1         ;主站请求读数据
	      movf        txdat9,0
	      xorlw       H'04'
	      btfsc       status,2
	      goto        sio_write_data         ;主站请求写数据 	            
	      movf        txdat9,0
	      xorlw       H'0f'
	      btfsc       status,2
	      goto        sio_change_mima         ;修改密码 
	      goto        sio_errff               ;出错处理
sio_read_data1               
            movf        txdat10,0
	      xorlw       H'02'
	      btfss       status,2
	      goto        sio_relay        ;sio_errff
			  
	      movf        txdat12,0
	      xorlw       h'0e8'
	      btfsc       status,2
	      goto        sio_read_86             ;郑州协议
			  
	        movf        txdat12,0
              xorlw       H'c0'
              btfsc       status,2
              goto        sio_read_brefer0        ;读表表号和常数   
              
              movf        txdat12,0
              xorlw       H'c1'
              btfsc       status,2
              goto        sio_read_csem           ;读起始电量               
              
              movf        txdat12,0
              xorlw       H'90'
              btfsc       status,2
              goto        sio_read_bem            ;读本月电量    

              movf        txdat12,0
              xorlw       H'0e4'
              btfsc       status,2
              goto        sio_read_zheng            ;郑州协议  
              goto        sio_errbs               ;数据标识错误
;*************************************** 
;读取本月电量
sio_read_bem
              movf        txdat11,0
              xorlw       H'1f'
              btfss       status,2    
	      goto        $+2
              goto        sio_read_em1f    
              movf        txdat11,0
              xorlw       H'10'
              btfss       status,2    
	      goto        sio_errbs
          ;    goto        sio_read_em10  
sio_read_em10
              call        sio_read_bem0
              movlw       .6
              movwf       txdat10
              goto        sio_tx  
sio_read_em1f
              call        sio_read_bem0
              movlw       txdat17
              movwf       fsr
              movlw       .16
              movwf       r2
              clrf        indf
              incf        fsr
              decfsz      r2
              goto        $-3
              movlw       .22
              movwf       txdat10
              goto        sio_tx
sio_read_bem0
              movlw       aen1_zong
              movwf       r0
              movlw       txdat13 
              movwf       r1
              movlw       4
              movwf       r2
              call        ram_copy
              retlw       0
sio_read_csem
              movf        txdat11,0
	        xorlw       H'19'
		  btfss       status,2
              goto        sio_errbs
              movlw       i2c_cs_aen1
              movwf       iic_addr
              movlw       txdat13
              movwf       iic_back_addr
              movlw       04
              movwf       iic_count
              call        iic_read
              movlw       .6
              movwf       txdat10
              goto        sio_tx  
;***************************************  
sio_read_brefer0 
		      movf        txdat11,0
		      xorlw       H'30'
		      btfsc       status,2
		      goto        sio_read_constant          ;读取脉冲常数,3个字节
		      movf        txdat11,0
		      xorlw       H'32'
		      btfsc       status,2
		      goto        sio_read_bh                ;读取表号,6个字节	       
		      goto        sio_errbs           
;读取脉冲常数 
sio_read_constant  
		      movlw       txdat13
		      movwf       fsr
		      clrf        indf
		      incf        fsr
		      movf        metercons,0
		      movwf       indf
		      incf        fsr
		      clrf        indf
	              movlw       .5
	       	      movwf       txdat10
	              goto        sio_tx
;读取表号 
sio_read_bh
		      movlw       id1            ;表号1,最低位
		      movwf       r0
		      movlw       txdat13
		      movwf       r1
		      movlw       .6             ;表号共有6位
		      movwf       r2
		      call        ram_copy   
		      movlw       .8
	              movwf       txdat10
	              goto        sio_tx   
;--------------------------------------
sio_read_zheng
              movf        txdat11,0
              xorlw       H'11'
              btfsc       status,2
              goto        sio_read_ccbh         ;读局编号 
              movf        txdat11,0
              xorlw       H'12'
              btfsc       status,2
              goto        sio_read_jbh      ;读出厂编号
              goto        sio_errbs
;--------------------------------------
sio_read_jbh
              movlw       i2c_jbh1
              movwf       iic_addr
              movlw       txdat13
              movwf       iic_back_addr
              movlw       .12
              movwf       iic_count
              call        iic_read
              movlw       .14
              movwf       txdat10
              goto        sio_tx 
sio_read_ccbh
              movlw       i2c_ccbh1
              movwf       iic_addr
              movlw       txdat13
              movwf       iic_back_addr
              movlw       .5
              movwf       iic_count
              call        iic_read
              movlw       .7
              movwf       txdat10
              goto        sio_tx                
;**************************************
sio_relay

⌨️ 快捷键说明

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