Weird, I would try something
ANSEL is not set, set it so the unused Analog pin will be digital
Increase your ADC Sampling Time, set Fosc to Frc.
This should do the trick.
Weird, I would try something
ANSEL is not set, set it so the unused Analog pin will be digital
Increase your ADC Sampling Time, set Fosc to Frc.
This should do the trick.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
My apologies, I stripped out some linesfrom my program (ie a list of what I have attached to all the pins), to condense the code & make it eaasier to read , it seems I got carried away with the delete key when posting
....that above bit missing from my original code.Code:TRISA = %11001010 'RA2 hpwm out therefore output needed ANSELA =%00000010 'SIG in (RA1) NEED TO BE ANALOGUE.
I'll try increasing the sampling time (but not sure why it would be 'signal level' sensitive....ie above a few millivolts right up to VCC, the ADC reads fine)
Walter....oh dear, not what I wanted to hear (re your problems). I did read the errata sheet, but that seems to relate more to ADC not completing (hanging?) under certain circumstances.... whereas this appears to be working as it should my readings are totally fine above 008 upto 255 ....just can't get under 008...even short to the PIC's ground pin.
I've only recently progressed from using ADCIN ...I'm just using it here cos it's quick!
Edit: just tried setting the Fosc to Frc ....hmmm, I won one bit back ...my ADC now reads between 007 & 255!
Last edited by HankMcSpank; - 19th May 2011 at 18:20.
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!
Last edited by HankMcSpank; - 19th May 2011 at 20:00.
That's interesting. I also thought the WeakPullups could do something but never had this problem before. Nice finding.
So I guess doing the ADC while sleeping would also have do the trick.
Since it's working... don't fix it![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Nothing whacky there.
The WPUA register defaults to %00111111 on power-up.
If you do WPUA.3 = 1
nothing changes, because that bit is already a 1.
You have to disable pull-ups on the pins you don't want pulled-up.
The numbers over each bit show the POR/BOR defaults.
![]()
DT
For once you' re wrong (& I've got you on a minor technicality!) - there was something whacky - ME!
I guess (me aside) the other whacky thing was even with weak pullups enabled ...my ADC pin still functioned.....albeit only down to a reading of 008 (whenever I've set an ADC pin wrong prior...I've had very "something oviously wrong with my config" type results ...this one was more obscure!)
Anyway, apologies for the schoolboy error....
Last edited by HankMcSpank; - 19th May 2011 at 21:31.
must do mistake from time to time... this is the best way to learn![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks