Je m'adresse plus particulierement à notre specialiste ASm , Maï
J'ai testé un capacimetre , seffmetre LC Meter à partir d'un programme pris sur le Web
et j'ai de gros doute sur cette partie de programme, bien que celui ci tourne sans probleme (apparent).
Tous les details ICI .
TMR0 est utilisé pour mesure la frequence de l'oscillateur LC
Pour moi , RA4 ne peut etre qu'une ENTREE pour le timer TMR0
et je ne comprends pas pourquoi RA4 est configuré en Sortie
pour la Mesure, pendant 100mS
puis en entree pour utiliser T0SE comme entree soft de Timer0
; OPEN GATE
movlw b'11100111' ; Enable RA4 output to T0CKI
movwf TRISA ; EN SORTIE ?
CALL MS100 ; 100MS DELAY
; CLOSE GATE (COUNT COMPLETE)
movlw b'11110111' ; Disable RA4 output to T0CKI
movwf TRISA ; en ENTREE ?
J'aurais plutot fait le contraireJ'ai deja utilisé RA4 en entree .. de frequencemetre sur 16F84 ..
pourtant, si j'inverse .. le programme ne tourne plus correctement .. "OVERRANGE"
Code : Tout sélectionner
Measure
bcf INTCON,T0IF ; Declare "Not yet Over-range"
CLRF TMR0 ; RESET INTERNAL COUNT (INCLUDING PRESCALER)
; See page 27 Section 6.0
CLRF F3 ; Ready to receive 16 bit number
CLRF F3+1
bank1
; OPEN GATE
movlw b'11100111' ; Enable RA4 output to T0CKI
movwf TRISA ; 1 = input 0 = output
CALL MS100 ; 100MS DELAY
; CLOSE GATE (COUNT COMPLETE)
movlw b'11110111' ; Disable RA4 output to T0CKI
movwf TRISA ; 1 = input 0 = output
bank0
MOVF TMR0,W ; GET HIGH BYTE
MOVWF F3 ; Copy to Big end of 16 bit result
; The comparator is "outputting" a 1 'cos we've forced it high
; so T0CKI=1.
PSC1
bank1
bsf OPTION_REG,T0SE ; Clock the prescaler
nop
bcf OPTION_REG,T0SE
bank0
DECF F3+1,F ; Decrement the counter
movf TMR0,W ; Has TMR0 changed?
xorwf F3,W ; if unchanged, XOR -> 0
beq PSC1
return ; F3 : F3+1 now holds 16 bit result
un petit bout de schema pour aider
;9.5 Comparator Outputs
;The comparator outputs are read through the CMCON
;register. These bits are read only. The comparator
;outputs may also be directly output to the RA3 and RA4
;I/O pins. When the CM<2:0> = 110
une sortie va en principe sur une entree ?
Bref , pas clair du tout dans la datasheet ..

