PDA

View Full Version : 16F88 -- weird stuff Ansel?



Michael
- 2nd February 2020, 17:49
One of those twilight zone problems going on -- not worth explaining but let me ask....

ANSEL = 0

CMCON = 7

That's what I have for my 16F88.

I need ALL pins digital. Port A and B. And just that, no ADC, no nothing but 16 inputs and outputs.

Is there something quirky about the 16F88 I'm missing? Just simply trying to toggle an output hi/lo (along with much other code) and stumped.

Is the ansel and cmcon setup right for what I want? thanks

Michael
- 2nd February 2020, 18:04
every ^&&% time I post a question, 5 minutes later I figure it out.

added ADCON1 = 7


confirm anyone? that this must be there for my 16 I/O ? working now.

HenrikOlsson
- 2nd February 2020, 21:35
Hi,
ANSEL = 0 for sure.
CMCON = 7 why not, but it's the default POR value so really shouldn't be needed (as long as the datasheet isn't lying to us).
ADCON1 = 7 don't know how you came up with that value or how it would help (if it acually did). The four lower bits are unimplemented and does nothing so Writing 7 to that regiser does exactly that - nothing.

So, as far as I can see, clear ANSEL and clear TRIS bits for your outputs should do it.

/Henrik.

Michael
- 3rd February 2020, 15:46
yeah, I think the adcon1 addition was my imagination. still acting up. what I'm trying to do is simple look at the data output from an infrared receiver on an input pin (with a pullup) and check for a low. works fine on a breadboard (just doing that with a few lines of code in a loop) but when I try to implement it in some code which has a lot going on, it's haphazard. I've tried using a for next loop so it stays on the input pin, checking a thousand times and even tried a goto where it loops for a few seconds using a counter. (a few seconds would be more than enough to "catch" the pin going low). tried a voltage divider on the pin trying to push it lower to ground, etc. not having much luck.

But I'll probably figure out after I post this :) --as always

peterdeco1
- 3rd February 2020, 16:24
Michael I only needed to use the 'F88 for 1 project. Here is my header. I never had any trouble with the inputs or outputs.

OSCCON = $60 'set int osc to 4mhz
ANSEL = 0 ANALOG INPUTS NONE
ADCON0 = 0 'AD MODULE OFF & CONSUMES NO CURRENT
CMCON = 7 'COMPARATORS OFF (DEFAULT ON POR)

mpgmike
- 4th February 2020, 00:22
If that doesn't work, post your entire code, including your CONFIGuration bits. Use [ CODE] and [/CODE] (without the spaces) to compartmentalize your code in the forum posting.