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

📄 zz-yjcut.asm

📁 pic资料
💻 ASM
📖 第 1 页 / 共 5 页
字号:
	    movwf       tmr1h
          movlw       tmr1l_cons2byte  
          movwf       tmr1l
          goto        init_over
sio_tx_fe  
          btfsc       tx_sta,2
          goto        sio_tx_stopfe 
          btfsc       tx_sta,3
          goto        sio_tx_byte_loop
          bsf         tx_sta,3
          movf        tx_buff,0
          movwf       temp1
          call        sio_byte_cs
          goto        sio_tx_byte_loop 
sio_tx_stopfe
          bcf         flag,6
          bsf         tx_pin
          movlw       tmr1h_cons833
	    movwf       tmr1h
          movlw       tmr1l_cons833
          movwf       tmr1l
          movlw       txdat1
	    movwf       fsr  
          clrf        rx_count
          clrf        tx_count 
          clrf        tx_sta
          clrf        rx_sta
          goto        init_over   
;-----------------------------------------     
sio_tx_stop  
          bsf         tx_pin
          movlw       tmr1h_cons833
	    movwf       tmr1h
          movlw       tmr1l_cons833
          movwf       tmr1l
          clrf        tx_sta           
          movf        tx_count,0
          xorlw       .28
          btfss       status,2
          goto        $+5
          btfsc       bzreg,5
          goto        sio_normal
          btfsc       bzreg,7 
          goto        init_overzz8          
          movf        tx_count,0
          xorlw       .38
          btfss       status,2
          goto        $+3 
          btfsc       bzreg,7
          goto        init_overzz41
sio_normal
          incf        tx_count
          incf        tx_fsr
          movf        tx_fsr,0
          movwf       fsr
          movf        indf,0
          movwf       tx_buff
          movf        tx_count,0
          xorwf       length,0
          btfss       status,2
          goto        init_over
          
          bsf         usart_wr
          clrf        length 
          movlw       0xfd      ;;movlw       tmr1h_cons833
	  movwf       tmr1h
          movlw       0x00      ;;movlw       tmr1l_cons833
          movwf       tmr1l
          goto        init_over  
;******************************************* 
relay_delay
          bcf         status,0
          bsf         status,5
          movf        relay_cnt1,0
     	  addlw       1
          movwf       relay_cnt1
          btfss       status,0          
          retlw       0                      
 ;         bcf         status,0 
          incf        relay_cnt2
          retlw       0 
;******************************************* 
start      
         clrwdt   
         bsf           status,5
         movlw         b'00001000'
         movwf         trisa
         movlw         b'01101000' ;b'01101000'
	 movwf         trisb 
         movlw         b'00100000' ;b'00010000'
         movwf         trisc 	 
	 clrf          sspstat  
         clrf          pie1
         bsf           pie1,0  
	 movlw         b'00000110'
         movwf         adcon1              ;关闭A/D功能
         movlw         b'00001110'         
	 movwf         option_reg   
	       
;	 clrf          relay_cnt1
;        clrf          relay_cnt2
         clrf          display_cn1
         clrf          display_cn2
         clrf          flag_display

 	   bcf           status,5          
         clrf          t1con      
         clrf          adcon0
         clrf          intcon
	   clrf          sspcon 
	   bcf           relay_on
         bcf           relay_off 	 
         call          delay 
         call          initlcd
         call          initlcd
         clrf          bzreg  
         clrf          length 
         clrf          rx_count
         clrf          rx_sta
         clrf          tx_sta
         clrf          zz_cnt  
  
         movlw         60
         movwf         iic_addr
         movlw         bcd1
         movwf         iic_back_addr
         movlw         02
         movwf         iic_count
         call          iic_read
         movf          bcd1,0
         xorlw         .44
         btfss         status,2
         goto          power_first
         movf          bcd2,0
         xorlw         .11
         btfsc         status,2 
         goto          power_later   
power_first
         clrf          aen1_zong
         clrf          aen2_zong
         clrf          aen3_zong
         clrf          aen4_zong
         clrf          aen_plusnum
         movlw         50h
         movwf         num2 

         movlw         .44
         movwf         bcd1
         movlw         .11
         movwf         bcd2
         movlw         60
         movwf         iic_addr
         movlw         bcd1
         movwf         iic_back_addr
         movlw         .2
         movwf         iic_count
         call          iic_write 
power_later
         movlw         00
         movwf         iic_addr
         movlw         aen1_zong
         movwf         iic_back_addr
         movlw         08
         movwf         iic_count
         call          iic_read
  
         movlw         10
         movwf         iic_addr
         movlw         id1
         movwf         iic_back_addr
         movlw         06
         movwf         iic_count
         call          iic_read
      
         bsf           usart_wr
         movlw         tmr1h_cons278
         movwf         tmr1h
         movlw         tmr1l_cons278
         movwf         tmr1l
         bsf           tx_pin
         bcf           pir1,0
         bsf           t1con,0
         bsf           intcon,7
         bsf           intcon,6 
sin38k       
        movlw       	.13
	movwf       	ccpr1l
	bsf         	status,5
	movlw       	.26
	movwf        	pr2
        bcf        	status,5
	movlw       	b'00001100'
	movwf       	ccp1con          ;open pwm
        bsf         	t2con,2          ;open tmr2      
;******************************************* 
main     
         clrwdt   
         call          relay_time   
         bcf           status,5 
         call          aem_add  
         call          code485
         call          lcd_display
         btfss         pdown   ;portb,5 
         goto          $+3        
         call          protect 
         goto          $+2
         bcf           flag,0              
         call          protect_ontime
         call          code485
         bsf           intcon,7
         bsf           intcon,6
         btfss         pdown  ;portb,5 
         goto          $+3        
         call          protect 
         goto          $+2
         bcf           flag,0   

         btfsc         pdtest
         bsf           relay_led  
         btfss         pdtest
         bcf           relay_led 
         goto          main 
;******************************************* 
relay_time         
         btfss       flag,2
         retlw       0
         bsf         status,5
         movf        relay_cnt2,0
         xorlw       .09
         btfss       status,2
         retlw       0 
         clrf        relay_cnt1
         clrf        relay_cnt2

         bcf         status,5
         bcf         relay_on
         bcf         relay_off
         bcf         flag,2
         call        sio_relay_ret  
         retlw       0 
;******************************************* 
read_cons
         bcf           flag,5
         movlw         i2c_cons
         movwf         iic_addr
         movlw         metercons
         movwf         iic_back_addr
         movlw         1
         movwf         iic_count
         call          iic_read
         retlw         0
;******************************************
aem_add 
    	bcf           flag,4
    	btfsc         cf
     	bsf           flag,4
aensum   
		btfss         cf
		goto          sumaen_clear
		call          delay 
		btfss         cf
		goto          sumaen_clear
		btfss         flag,4
		goto          sumaen_clear
		btfsc         flag,7         ;是否已经累加过当前的CF
		retlw         0	 
                movf          num2,0
                xorlw         0
                btfsc         status,2 
                goto          power_on
                incf          num2
                movf          num2,0
                andlw         0fh
                sublw         .10
                btfsc         status,0
                goto          $+2
                clrf          num2
power_on
		incf          aen_plusnum
		bsf           flag,7  
		movlw         0x08
		xorwf         metercons,0
		btfsc         status,2
		goto          metercons800
		movlw         0x16
		xorwf         metercons,0
		btfsc         status,2
		goto          metercons1600
		movlw         0x32
		xorwf         metercons,0
		btfsc         status,2
		goto          metercons3200
		movlw         0x64
		xorwf         metercons,0
		btfsc         status,2
		goto          metercons6400  
                call          read_cons
		retlw         0 
sumaen_clear
        	bcf           flag,4
        	bcf           flag,7 
         	retlw         0
;--------------------------------------
metercons800
		 movlw         0x08
		 xorwf         aen_plusnum,0
		 btfss         status,2
		 retlw         0
		 clrf          aen_plusnum
		 call          aensum_add
		 clrf          num1
		 retlw         0
;--------------------------------------
metercons1600
		 movlw         0x10
		 xorwf         aen_plusnum,0
		 btfss         status,2
		 retlw         0
		 clrf          aen_plusnum
		 call          aensum_add
		 retlw         0
;--------------------------------------
metercons3200
		 movlw         0x20
		 xorwf         aen_plusnum,0
		 btfss         status,2
		 retlw         0
		 clrf          aen_plusnum
		 call          aensum_add
		 retlw         0
;--------------------------------------
metercons6400
		 movlw         0x40
		 xorwf         aen_plusnum,0
		 btfss         status,2
		 retlw         0
		 clrf          aen_plusnum
		 call          aensum_add
		 retlw         0
;--------------------------------------
aensum_add   
;            clrwdt
		bsf     num1,0
		movf    aen1_zong,0
		call    tiaozheng
		movf    bcd3,0      ;r3,0
		movwf   aen1_zong
		
		movf    aen2_zong,0
		call    tiaozheng
		movf    bcd3,0      ;r3,0
		movwf   aen2_zong
		
		movf    aen3_zong,0
		call    tiaozheng 
		movf    bcd3,0      ;r3,0
		movwf   aen3_zong
		
		movf    aen4_zong,0
		call    tiaozheng
		movf    bcd3,0      ;r3,0
		movwf   aen4_zong
		bcf     num1,0
		retlw   0
tiaozheng 
		movwf  bcd3         ;r3
		bcf    status,0
		btfsc  num1,0
		incf   bcd3         ;r3
		bcf    num1,0
		movf   bcd3,0         ;r3,0
		andlw  0fh
		sublw  .9
		btfsc  status,0
		retlw  0
		movf   bcd3,0         ;r3,0
		addlw  10h 
		movwf  bcd3         ;r3
		andlw  0f0h 
		movwf  bcd3         ;r3
		sublw  9fh
		btfsc  status,0
		retlw  0
		clrf   bcd3         ;r3
		bsf    num1,0
		retlw  0
;--------------------------------------
protect_ontime
;时时保护的程序,每两度电保存一次。 
         btfss         aen2_zong,0 
         goto          $+3
         bcf           flag,3
         retlw         0
         btfsc         flag,3
         retlw         0  
         bsf           flag,3      
         call          iic_save
         retlw         0 
protect 
       call          delay
       btfss         pdown  ;portb,5
       retlw         0
       btfsc         flag,0
       retlw         0
       bsf           flag,0
       
       movf          num2,0
       xorlw         0
       btfss         status,2
       retlw         0

       movlw         50h
       movwf         num2
       call          iic_save  
       call          delay    
       bsf           status,5
       movlw         b'00001111'         
       movwf         option_reg  
       bcf           status,5
       clrwdt      

⌨️ 快捷键说明

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