Thanks for the moral support (& the idea, which sounds great!)
Like I say, I'm out my depth & frankly I need to go & learn about timers now (never had to use 'em before)
So my next 'challenge' is o find a way of ensuring that Timer1 is seeing (counting) pulses in from C2out at the T1CKI Pin (I've a sneaking suspiscion, that that's going to be like drawing back teeth for me). I'm pretty sure it's not counting pulses yet, I took a bit of a flyer & lifted the parts I thought were most appropriate rom byte_butchers code...
Code:
DEFINE OSC 4
DEFINE DEBUG_REG PORTA
DEFINE DEBUG_BIT 0 ' RA0 = TX out to PICKit2 programmer USART tool
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 0 ' 1 = inverted, 0 = true
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 1 ' Set clock source Fosc/8 "2uS"
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
CM1CON0= %10010100 'from the Microchip AN1011a application note.
CM2CON0= %10100000 'from the Microchip AN1011a application note.
CM2CON1= %00110010 'from the Microchip AN1011a application note.
SRCON = %11110000 'from the Microchip AN1011a application note.
VRCON = %10000111 'from the Microchip AN1011a application note.
ANSEL = %00001010 'AN1 & AN4 analogue, the rest Digital.
TRISA = %11111011 'RA1 (C12IN0-) as input, RA2 (C1Out ) output RA5 Input (T1CKI)
TRISC = %00000011 'RC0 (VCC/4) as input, RC1 Input (not sure if it's in scope either), RC4 output (C2OUT)
' the above seems to get me my oscillator output.
'Timer Setup (all byte_butcher's code & likely not going to work with the 16F690)
T2CON = %01110110 'bit7=unimplemented, bit6-3=postscaler, bit2=TMRON, bit1-0=prescaler
PR2 = %11111111 'give PR2 a number for TMR2 to match
PIR1.1 = 0 'Clear the TMR2 interupt flag
PIE1.1 = 1 'Turn TMR2 interrupt enable on
T1CON = %11000101 'Timer clock source=CAPOSC, prescale=1:1, dedicated OSC disabled, no external clock synchronize, timer on
PIR1.7 = 0 'Clear Gate Interrupt Flag
PIR1.1 = 0 'clear the TMR2 interupt flag
'-----Allocate Variables
timercount var word ' raw count from TMR1
timercount = TMR1L + TMR1H << 8
'----Main loop-----------------------------------------------------------
Main:
DEBUG " timerCount= ", DEC timercount, 13, 10
pause 100
GOTO Main
end
(the 'timercount' onscreen DEBUG output remains steadfastly at zero.... I guess I'm gonna have to get deep down 'n dirty & try & figure out all those specific Timer register settings are for the 16F690!
Once I'm sure my Timer1 is counting, then I guess I can enter the brave new world of getting creative with interupts!
Thanks once again.
Bookmarks