[an error occurred while processing this directive]
[an error occurred while processing this directive]
|
Извини, лень разбираться. Я лучше кину кусок своего кода, может, это поможет как-то
; ******************************************************************
; *** CCP2 service ***
; ********************
; 24-bit captured result is in CAP01H,CAP01M,CAP01L
; pulse is invertedL_INT_CCP2
clrf TMOUT ; clear time-out
btfss FLAGS,CAP01 ; 0-to-1 capture?
goto L_INT_CAP10 ; no; *************************************
; *** 0-to-1 capture (end of pulse) ***
; *************************************
; *** store CCPR2x
btfss PIR1,TMR1IF ; overflow?
goto L_01_CAP ; no
bcf PIR1,TMR1IF ; yes, clear int flag
incf T1CNTH ; increment counter extensionL_01_CAP
movf CCPR2H,W ; temp store
movwf CAP01M ;
movf CCPR2L,W ; temp store
movwf CAP01L ;; *** re-init CCP2 ASAP (As Soon As Possible)
movlw CCP2CON_CAP10_ ; next edge - pulse start
movwf CCP2CON ; set mode
bcf PIR2,CCP2IF ; clear int flag; *** capture T1CNT
L_INT_CAPT01
movf T1CNTH,W ; store T1CNT
movwf CAP01H ;; *** finally
bcf FLAGS,CAP01 ; next edge is 1-to-0
goto L_INT_CHECK ; exit to interrupt switching routine; **************************************
; *** 1-to-0 capture (pulse started) ***
; **************************************
L_INT_CAP10
btfss PIR1,TMR1IF ; TMR1 overflow?
goto L_10_CAP ; no
bcf PIR1,TMR1IF ; yes, clear int flag
incf T1CNTH ; increment MSB byte
L_10_CAP
movf CCPR2H,W ; temp store
movwf CAP10M ;
movf CCPR2L,W ; temp store
movwf CAP10L ;; *** re-init CCP2 ASAP
movlw CCP2CON_CAP01_ ; next edge - end of pulse
movwf CCP2CON ; set mode
bcf PIR2,CCP2IF ; clear int flag; *** capture T1CNT
movf T1CNTH,W ; store T1CNT
movwf CAP10H ;; *** finally
bsf FLAGS,CAP01 ; next edge is 0-to-1
goto L_INT_CHECK ; exit
Составить ответ ||| Конференция ||| Архив
Ответы
E-mail: info@telesys.ru