Hi,
I've been looking thru the datasheet to figure out what might be going on but I honestly can't find it.
So, I'm going to sugest that you might have a hardware issue, is this on a breadboard by any chance? Faulty contacts?
Going thru the datasheet I also noted the follwing regarding setting all those registers to 0 in your code:
REFCON0=0 (pg.247)
Defaults to 16 at POR which means that the FVR is set to 1.024V but disabled, setting it to 0 shouldn't be needed.
Instead, it specifically says not to use the value 0....
REFCON1=0 (pg.248)
Defaults to 0 at POR, DAC disabled, setting it to 0 shouldn't be needed.
ADCON1=0 (pg.216)
Defaults to 0 at POR, setting it to 0 shouldn't be needed.
ADCON2=0 (pg.217)
Defaults to 0 at POR, setting it to 0 shouldn't be needed.
ANSEL = 0 (pg.98)
Defaults to 248 at POR, setting it to 0 IS needed to enable the digital input buffers.
ANSELH = 0 (pg.99)
Defaults to 15 at POR, setting it to 0 IS needed to enable the digital input buffers.
CM1CON0=0 (pg.229)
Defaults to 0 at POR, comparator is disabled, setting it to 0 shouldn't be needed.
CM2CON0=0 (pg.230)
Defaults to 0 at POR, comparator is disabled, setting it to 0 shouldn't be needed.
SRCON0=0 (pg.242)
Defaults to 0 at POR, SR latch is disabled, setting it to 0 shouldn't be needed.
SRCON1=0 (pg.243)
Defaults to 0 at POR, SR latch is disabled, setting it to 0 shouldn't be needed.
WPUA=0 (pg.86)
Defaults to 56 at POR, PortA pulups enabled, setting it to 0 disables the pullups individually.
However, INTCON2.7 is the "master switch" PortA and PortB pullups and it defaults to 1 which means pullups are disabled.
So, if you're NOT clearing INTCON2.7 there shouldn't be any need to set WPUA=0
WPUB=0 (pg.91)
Defaults to 240 at POR, PortB pullups enabled, setting it to 0 disables the pullups individually.
However, INTCON2.7 is the "master switch" PortA and PortB pullups and defaults to 1 which means pullups are disabled.
So, if you're NOT clearing INTCON2.7 there shouldn't be any need to set WPUA=0
/Henrik.
Bookmarks