PDA

View Full Version : Upgraded to 2.60 ~ now it won't read pin 5, 16F876A.



kenif
- 11th August 2011, 21:19
Here's an interesting one.
Have 3 switches into a 16F876A; 10K pullups, 470pF slugs, active low.
Pins are high on scope. Existing product, worked forever. Tried new PICs.

After upgrading to 2.60, the PIC won't read one of the inputs, the PORTA.3.
Wrote this below to find out why existing program cannot read a high on pin 5.
Even driving from inside it doesn't see a high, but all other pins work as normal.
It doesn't have to be debug, no way of reading this pin seems to work.

Please tell me what I'm doing wrong.
Ken

Terminal output:

PORTA.3: 0 (should be 1)
PORTB.1: 1
PORTA.4: 1


Program:
'************************************************* ***************
'setup:

DEFINE OSC 20 ' set the clock speed

DEFINE DEBUG_REG PORTC ' Set Debug pin port
DEFINE DEBUG_BIT 6 ' Set Debug pin bit
DEFINE DEBUG_BAUD 9600 ' Set Debug baud rate
DEFINE DEBUG_MODE 0 ' Set Debug mode: 0=true(inv), 1=TTL

INCLUDE "modedefs.bas" ' must be in local directory

INPUT PORTA.3 ' set input

TRISA.3 = 1 ' set input (again)

test:

debug " PORTA.3: ", dec PORTA.3, 10, 13
debug " PORTB.1: ", dec PORTB.1, 10, 13
debug " PORTA.4: ", dec PORTA.4, 10, 13
debug 10, 13
pause 500

goto test

end

Bruce
- 11th August 2011, 21:37
RA3 is analog by default until you disable it, and analog inputs read zero when trying to use as digital inputs.

kenif
- 12th August 2011, 04:50
Bruce, once again you saved my bacon.
The real mystery is how this input worked for the last three years... going back through the old code now.

Thanks,
Ken.