The pinout usually give some great hints... AN like ANALOG.. so you want to disable the analog features of the offending pins...and have a look at this thread
http://www.picbasic.co.uk/forum/showthread.php?t=561
The pinout usually give some great hints... AN like ANALOG.. so you want to disable the analog features of the offending pins...and have a look at this thread
http://www.picbasic.co.uk/forum/showthread.php?t=561
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I am able to read each pin separately without any problems.
This works:
if (portb.2 = 0) Then do something
So does this:
if (portb.3 = 0) Then do something
So does this:
if (portb.4 = 0) Then do something
However, if I check all three immediately after one another, I am getting funny results. Do I need to let portb 'rest' in-between reads, etc? Is there something I am missing?
I have set the registers as per the datasheet for the 16f887:
CM1CON0=%00000000 'disable COMPARATOR 1
CM2CON0=%00000000 'disable COMPARATOR 2
trisb = %11111111 'set all pins to input
Any ideas?
Maybe the victim of R-M-W? I am guessing the do something part may be setting output pins high? If they are on the same port, maybe this is the problem. I like to grab the input port and put it in a variable. Then I can check the bits in the variable and do something -or not.
Just suggestions, I am not sure of the problem.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Nope.Maybe the victim of R-M-W?
Pins that power-up as analog inputs, when read (assuming it's a digital input), will read ZERO unless you have disabled the analog peripheral on the pin you're reading.
TIP: Look at ANSELH.
I'll bet, if you set all of these pins to logic 1 (externaly), they still all read zero until you disable the analog periperal!
Last edited by Bruce; - 30th July 2011 at 23:21.
I have set:
ANSELH=%00000000
If I check for say a portb.3 button press, it works fine. If I check for a portb.5 button press it works fine.
However, if I check for say portb.3 and then portb.5 straight away, sometimes portb.5 comes back as 1 instead of 0, etc.
Post your code. It's tough to help troubleshoot what we can't see..![]()
But, in 2011, everything's possible
![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks