• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::

論壇索引


Board index » All Posts (shiang)




麻煩各位程式高手
#1
新會員
新會員


DEAR ALL~~
以下是一者PIC16F877單晶片的程式,請問一下各位高手,有時可以幫我把它註解一下,謝謝各位好心人士。
;   ----  " Single - Channel Lives " of " AS-50 Trigger" Shutter Driver Circuit.  ----                         

                 LIST        
p=16f877
             
#INCLUDE   <p16f877.inc>
                                       
BKP_L_IO_F       EQU         0x20                
BKP_T_IO_F       EQU         0x21                
CTR_L_IN_F       EQU         0x22                
CTR_T_IN_F       EQU         0x23                          
CTR_L_SHUT_F     EQU         0x24                
CTR_T_SHUT_F     EQU         0x25                
DLY_TIME_F       EQU         0x26  
DLY_XMS_F        EQU         0x27
TMR_OFF_L_F      EQU         0x28               
TMR_OFF_T_F      EQU         0x29                     
TMR0_CT_F        EQU         0x2A
TMR0_SHUT_F      EQU         0x2B
TMR0_WIDE_F      EQU         0x2C
TMR0_XS_F        EQU         0x2D
TMR0_XMS_F       EQU         0x2E
XOR_CT_F         EQU         0x2F           
XOR_IN_F         EQU         0x30            
XOR_SHUT_F       EQU         0x31                
CTR_SKIP_F       EQU         0x32                

                 ORG         0x00
                                       
Initial
:      
                 
clrw
                 banksel     TRISC                       
                 movlw       
B'00000011'        
                 
movwf       TRISC               

                 clrf        TRISA               
                 clrf        TRISB               
                 clrf        TRISD               
                 clrf        TRISE               
   
                 banksel     PORTA                    
                 clrf        PORTA               
                 clrf        PORTB             
                 clrf        PORTC
                 clrf        PORTD                
                 clrf        PORTE               
      
                 clrf        BKP_L_IO_F          
                 clrf        BKP_T_IO_F
                 clrf        CTR_L_IN_F          
                 clrf        CTR_T_IN_F   
                 clrf        CTR_L_SHUT_F
                 clrf        CTR_T_SHUT_F
                 clrf        DLY_TIME_F   
                 clrf        DLY_XMS_F
                 clrf        TMR_OFF_L_F 
                 clrf        TMR_OFF_T_F
                 clrf        TMR0_CT_F 
                 clrf        TMR0_SHUT_F
                 clrf        TMR0_WIDE_F
                 clrf        TMR0_XS_F 
                 clrf        TMR0_XMS_F
                 clrf        XOR_CT_F
                 clrf        XOR_IN_F
                 clrf        XOR_SHUT_F
                 clrf        CTR_SKIP_F

Start
:        
                 goto        
Reset
A0
:
                 
call        Load_Input
                 call        Process          
                 call        Backup
                 call        Save_Output 
                 
goto        Delay_Time                      

Reset
:
                 
btfss       PORTC,1
                 
goto        A0
                 movlw       
B'01110000'         
                 
movwf       PORTC
                 call        Delay_5ms
                 movlw       
B'00010000'         
                 
movwf       PORTC
                 call        Delay_45ms
                 movlw       
B'10010000'         
                 
movwf       PORTC
                 call        Delay_5ms
                 movlw       
B'00010000'         
                 
movwf       PORTC
                 call        Delay_45ms
                 bcf         PORTC
,4
                 call        Delay_150ms         
                 
goto        Start

Load_Input
:
                 
movf        PORTC,w             
                 movwf       BKP_T_IO_F       
                 
return

Backup:
                 
movf        BKP_T_IO_F,w
                 movwf       BKP_L_IO_F
                 movf        CTR_T_IN_F
,w
                 movwf       CTR_L_IN_F
                 movf        CTR_T_SHUT_F
,w        
                 movwf       CTR_L_SHUT_F  
                 movf        TMR_OFF_T_F
,w
                 movwf       TMR_OFF_L_F
                 
return 

Save_Output:             
                 
movf        BKP_T_IO_F,w    
                 movwf       PORTC  
                 
return
            
Delay_5ms:
                 
movlw       D'5'
                 
movwf       DLY_XMS_F
G0
:
                 
call        Delay_1ms
                 decfsz      DLY_XMS_F
,f
                 
goto        G0
                 
return

Delay_45ms:
                 
movlw       D'45'
                 
movwf       DLY_XMS_F
G1
:
                 
call        Delay_1ms
                 decfsz      DLY_XMS_F
,f
                 
goto        G1
                 
return

Delay_150ms:
                 
movlw       D'150'
                 
movwf       DLY_XMS_F
G2
:
                 
call        Delay_1ms
                 decfsz      DLY_XMS_F
,f
                 
goto        G2
                 
return

Delay_1ms:
                 
movlw       D'245'         
                 
movwf       DLY_TIME_F
G3
:
                 
nop
                 decfsz      DLY_TIME_F
,f
                 
goto        G3
                 
return

Delay_Time:
                 
movlw       D'225'              
                 
movwf       DLY_TIME_F
G4
:
                 
nop
                 decfsz      DLY_TIME_F
,f
                 
goto        G4
                 
goto        Start

Process
:

Compare_0:
                 
movf        BKP_T_IO_F,w                   
                 xorwf       BKP_L_IO_F
,w
                 movwf       XOR_IN_F

Process_0
:
                 
movf        TMR0_CT_F,f
                 btfsc       STATUS
,Z
                 
goto        B0
                 decfsz      TMR0_CT_F
,f
                 
goto        Process_1
B0
:
                 
btfss       XOR_IN_F,0
                 
goto        Process_1
                 btfss       BKP_T_IO_F
,0
                 
goto        B2
                 btfss       CTR_L_IN_F
,0
                 
goto        B1
                 bcf         CTR_T_IN_F
,0
                 bcf         TMR_OFF_L_F
,0
                 bcf         TMR_OFF_T_F
,0
                 clrf        TMR0_XS_F
                 clrf        TMR0_XMS_F              
                 
goto        B2
B1
:
                 
bsf         CTR_T_IN_F,0
                 bsf         TMR_OFF_T_F
,0
                 movlw       D
'2'                
                 
movwf       CTR_SKIP_F
                 movlw       D
'30'               
                 
movwf       TMR0_XS_F
                 movlw       D
'100'              
                 
movwf       TMR0_XMS_F
B2
:
                 
movlw       D'200'               
                 
movwf       TMR0_CT_F

Process_1
:
                 
movf        TMR0_XMS_F,f
                 btfsc       STATUS
,Z
                 
goto        C0
                 decfsz      TMR0_XMS_F
,f
                 
goto        Compare_1
C0
:
                 
movf        TMR0_XS_F,f
                 btfsc       STATUS
,Z
                 
goto        C1
                 decfsz      TMR0_XS_F
,f
                 
goto        C2
C1
:       
                 
bcf         CTR_T_IN_F,0
                 bcf         TMR_OFF_T_F
,0
                 
goto        Compare_1     
C2
:
                 
movlw       D'100'
                 
movwf       TMR0_XMS_F

Compare_1
:
                 
movf        CTR_T_IN_F,w
                 xorwf       CTR_L_IN_F
,w
                 movwf       XOR_CT_F 

Process_2
:
                 
btfss       XOR_CT_F,0
                 
goto        D1
                 btfss       CTR_T_IN_F
,0
                 
goto        D0
                 bsf         CTR_T_SHUT_F
,0
                 
goto        D3         
D0

                 
bcf         CTR_T_SHUT_F,0        
                 clrf        TMR0_SHUT_F
                 
goto        Compare_2
D1
:
                 
btfss       CTR_T_IN_F,0
                 
goto        Compare_2
                 decfsz      TMR0_SHUT_F
,f
                 
goto        Compare_2
                 btfsc       CTR_T_SHUT_F
,0
                 
goto        D2
                 bsf         CTR_T_SHUT_F
,0
                 
goto        D3
D2
:
                 
bcf         CTR_T_SHUT_F,0
D3
:
                 
movlw       D'250'               
                 
movwf       TMR0_SHUT_F          

Compare_2
:
                 
movf        CTR_T_SHUT_F,w
                 xorwf       CTR_L_SHUT_F
,w
                 movwf       XOR_SHUT_F 

Process_3
:
                 
movf        TMR0_WIDE_F,f
                 btfsc       STATUS
,Z
                 
goto        E0
                 decfsz      TMR0_WIDE_F
,f
                 
goto        Process_5
                 bcf         BKP_T_IO_F
,6
                 bcf         BKP_T_IO_F
,7
E0
:
                 
btfss       XOR_SHUT_F,0
                 
goto        Process_5
                 btfss       CTR_T_SHUT_F
,0
                 
goto        E1
                 bsf         BKP_T_IO_F
,6
                 bcf         BKP_T_IO_F
,7
                 
goto        E2
E1
:
                 
bcf         BKP_T_IO_F,6
                 bsf         BKP_T_IO_F
,7
E2
:
                 
movlw       D'5'
                 
movwf       TMR0_WIDE_F

Process_4
:
                 
movf        CTR_SKIP_F,f        
                 btfsc       STATUS
,Z
                 
goto        F0
                 decf        CTR_SKIP_F
,f
                 
goto        Process_5
F0
                 btfsc       BKP_T_IO_F
,6        
                 
goto        F1
                 bcf         BKP_T_IO_F
,5
                 
goto        Process_5
F1
:
                 
bsf         BKP_T_IO_F,5

Process_5
:
                 
btfsc       TMR_OFF_T_F,0       
                 
goto        F2
                 bcf         BKP_T_IO_F
,4
                 
return
F2:
                 
bsf         BKP_T_IO_F,4
                 
return

                 
END

發表於: 2009/10/29 16:18

Edited by Ryang on 2009年11月06日 13:27:26
Edited by Ryang on 2009年11月06日 13:27:57
頂部






:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------