well, I got to the bottom of it...something whacky going on here!
It's something to do with the way I'm setting the weak pullup register....
Firstly, I noticed that when I disabled weak pullups (I just took a flier!)
Code:
OPTION_REG.7 = 1 ' disable weak pullups
My ADC started reading down to zero as it should!
Sure enough when I enabled weak pullups again, the problem returned.
But this is where I’m obviously doing something wrong, this way actually works…
(I want weak pullups of RA3)
Code:
WPUA = %00001000
IOCAN = %00001000
…ie even with weak pullups enabled my ADC reads down to zero.
But if I do this….
Code:
WPUA.3 = 1
IOCAN.3 = 1
My ADC won’t read down below 008 again!
So to get ADC reading down to zero *with* weak pullups enabled on a 12LF1822, it must be set like this....
Code:
OPTION_REG.7 = 0
WPUA = %00001000
IOCAN = %00001000
Not sure if it makes any difference but my weak pullup is on the MCLR pin.
Anyway, I'm happy - it's sorted!
Bookmarks