Hmm (rubs chin, pretending to understand the significance of what you're saying - but nevertheless knowing full well it's *BAD*). As it goes, I was just about to say, I'm getting this when I compile...
"Symbol not previously defined (TMR1GIF)" (which may/may not be related to what you're saying, l- modified your files as per your instructions to byte_butcher - I'm out my depth at the moment...but learning fast!)
From the Microchip application note- http://ww1.microchip.com/downloads/e...tes/01101a.pdf (which embraces this method with the 16F690)...
"Once the oscillator is constructed, its frequency must
be monitored to detect the drop in frequency caused by
a finger press. Figure 5 shows a more complete schematic
where C2OUT not only drives the oscillator, but
also is fed into the clock input of Timer1, T1CKI. Each
time C2OUT changes from ‘0’ to ‘1’ Timer1 will increment.
Unhindered, Timer1 will increment non-stop and
eventually roll over, but this is not useful for capacitive
sensing.
To make it useful, a fixed time base is used to measure
the frequency over a defined period. Timer0 provides
this fixed period time base. At the start of a measurement,
Timer0 is cleared, and it will count up to 255 and
then it will overflow. On overflow, the Timer0 interrupt,
T0IF, causes the program to vector to the Interrupt Service
Routine. "
As a beginner, could you tell me the significance of your news...
1. I can't use your interupt routines?
2. Their proposed method wont work? even though from the same datasheet, they say this ...
"There are currently three families of PIC microcontrollers
able to use the method as shown. These are the
Microchip PIC16F616 family, PIC16F690 family and
PIC16F887 family."
Grateful for the clarification!
Last edited by HankMcSpank; - 22nd November 2009 at 22:19.
The significance is that you are trying to use features that your selected PIC does not have (TMR1GIF).
So you will need to make more than syntax changes to get it to work.
The overall method used will need to be different, and it's one that I have never investigated.
<br>
DT
Don't give up ...
I'm sure it can be done.
But copy/paste from a 16F726 program will only confuse you.
You've got an Oscillator running ...
So if the C2OUT pin were connected to the T1CKI pin, then Timer1 could count the pulses.
Make a "Time Base" with Timer2 and the CCP1 pin (a.k.a. HPWM at lowest freq) connected to the T1G pin.
Then use TMR2_INT to read the Timer1 value, which should be directly proportional to the frequency. Not sure how good the resolution will be, but that's what experimentation is for.
<br>
DT
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...
(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!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
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.
You're still copying from a 16F726 program ...
Just forget about byte_butchers code. It doesn't apply, because there is no CSM in the 16F690!
I'm purposely being vague here because you only spent 45 minutes on the last version. I know ... "pouring scorn" ...
To select the T1CKI pin as input to Timer1, T1CON.1 (TMR1CS) should be set to 1.
Other bits in T1CON might be different too.
And when I hinted to HPWM, it should have been a big red flag.
<br>
_________________
DT
Fishing is cruel, why would anyone teach people to fish?
Bookmarks