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!)
My ADC started reading down to zero as it should!Code:OPTION_REG.7 = 1 ' disable weak pullups
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)
…ie even with weak pullups enabled my ADC reads down to zero.Code:WPUA = %00001000 IOCAN = %00001000
But if I do this….
My ADC won’t read down below 008 again!Code:WPUA.3 = 1 IOCAN.3 = 1
So to get ADC reading down to zero *with* weak pullups enabled on a 12LF1822, it must be set like this....
Not sure if it makes any difference but my weak pullup is on the MCLR pin.Code:OPTION_REG.7 = 0 WPUA = %00001000 IOCAN = %00001000
Anyway, I'm happy - it's sorted!





Bookmarks