Hello Melanie. Hello Everyone. I have to apologize to you Melanie. I started a project using your Olympic Timer as the "heart" of a background timer, and before I got the chance to even TRY to get it to work, the project was killed. I will go back to it for educational purposes soon. I do have something strange going on now with a simple piece of code. Has this happened to anyone and does anyone have an explanation? I have encountered the same problem with both the 12F629 and the 12F675. In this case I'm using an ADC on the 'F675. Here is the code:
ANSEL = 0 'all inputs digital
CMCON = 7 'comparators off
trisio = %11111111 'all inputs for now
b0 VAR BYTE ' define names for variables
b1 VAR BYTE
start: ' this line is the key for fixing the problem!
ADCIN 0,b1
IF b1 = 000 Then start
LET b0 = b1
NAP 3
ADCIN 0,b1
IF b0 > b1 + 007 Then play
IF b0 < b1 - 007 Then play
GoTo start
play:
High GPIO.4
Pause 5000
Low GPIO.4
Pause 100
GoTo start
The ADC is detecting a voltage change during the NAP 3 period. If detected, GPIO.4 turns on a FET which powers about 10 LED's. The problem is that it works intermittently. Sometimes it's fine, sometimes GPIO.4 doesn't shut off. Here is what's making me crazy; the exact same program compiled for a 16LF818 (replacing GPIO with PORTB) works perfectly every time! On the 12F675, this is how I fixed it: I moved "start" to the first line of the program above the ANSEL = 0 line and the problem went away. Is this a "quirk" of 8-pin PIC's or am I missing something here? The circuit runs on a 3V battery and brownout detect is off. And with this, I have another question about the 'F675: ADCIN 0, ADCIN 1, ADCIN 2 all work perfectly. The 4th ADC input "ADCIN 4" does not work. If this is because of the way PBP defaults when the program is compiled, is there a source of information to find out exactly what features will be available on the PIC without specifying them in the header file? On the 16LF818, all 4 ADC's work after compiling. Thank you.
Bookmarks