I am using a PIC18(L)F1XK22. I'm trying to use timer 3 as a synchronous counter.
The PIC is running using the internal oscillator.
CONFIG FOSC = IRC ; Internal oscillator
This should turn off use of pin RA5 as an external oscillator.
T1OSCEN in T1CON is 0, TMR3CS in T3CON is 1. I have set the RA5 TRIS bit and cleared the RA5 WPU bit.
My problem is that pin RA5 (T13CLKI) looks like it has a active pull up or is being driven by something.
I have the following resistor network in front of RA5.
+5---10K------X-----24K----->RA5
Point X is driven by a hall effect sensor. When X is 0 volts, RA5 is 2.2 volts. Decreasing the 24K resistor to 10K reduces X to 1.1 volts. I have to reduce the resistor to about 4K before the counter works.
Here is the code I used to set up the timer...
#define TM3CK_TRIS TRISA,TRISA5,A
#define TM3CK_WPU WPUA,WPUA5,A
BCF PIE2,TMR3IE,A ; Disable Timer3 interrupt
BSF TM3CK_TRIS ; set RA5 (T13CKI) as input
BCF TM3CK_WPU ; disable weak pull up on RA5
; pull up and isolation resistor are external
CLRF TMR3H,A ; clear Timer 3
CLRF TMR3L,A
MOVLW 0x8F ; 1xxx xxxx RD16 16 bit read/write
; x0xx xxxx unused bit
; xx00 xxxx T3CKPS 1:1 prescale
; xxxx 1xxx T3CCP1 something to do with comparators
; xxxx x1xx T3SYNC Do not sychronize with external clock
; xxxx xx1x TMR3CS external clock from RA5 (T13CKI)
; xxxx xxx1 TMR3ON enable timer
MOVWF T3CON,A
BCF TM3CK_WPU
BSF INTCON2,RABPU,A ; disable all pull ups
The last two lines were added in a vain attempt to turn off all pull ups after the timer was started.
Any help or idea much appreciated.