PDA

View Full Version : I can't read some input pins on a PIC18F4620



chaneyv4
- 24th January 2014, 22:54
Please help me!
I cannot get my pic to read pins RB.0 or RB.1 or RB.2.

I want to trigger an interrupt on a PIC18F4620, by sending a pulse to INT0 from another pic. I couldn’t get it to work, so I made a test program to pulse on and off, also lighting a led on the sending pic, and lighting a led on the receiving pic if the change on the input pin is detected. If I send the pulse to RC.0, it works fine (variable abSend), but if I send the pulse to RB.0, RB.1 or RB.2 (variables picBint0, picBint1, picBint2) it does not seem to be reading the pins. If I touch a led connected through a resistor to the inputs, it flashes on and off, so I know the signal is getting to the pins.

I have tried replacing the pic (3 times, using anti-static precautions), replacing capacitors, disconnecting other parts of the circuit, connecting 10K pull-up resistors on unused input pins, and writing my code different ways. I think that if my code were bad, then it wouldn’t work on RC.0. I just comment out the lines for the pins that I am not testing (on sending and receiving pic), not changing any of the other code. Same result each time: works great on RC.0, and doesn’t work for RB.0, RB.1 or RB.2. I am doing this test with interrupts turned off.
I am totally stumped. Can someone please help me?

I have attached my circuit diagram.

Here is my relevant code:
TRISA = %11111111
TRISB = %11111111
TRISC = %00000001
TRISD = %00000110
TRISE = %11111111
INTCON = %00000000 'intcon.7 = 0 disables global interrupts
INTCON2 = %00010101
INTCON3 = %11010000
RCON.7 = 0 '0 = Disable priority levels on interrupts
PIE1.6 = 0 '0 = Disables the A/D interrupt
TestInt:
if picBint0 = 0 then 'this doesn't work
'if picBint1 = 0 then 'this doesn't work
'if picBint2 = 0 then 'this doesn't work
'if abSend = 0 then 'this works fine
testLed = 1
else
testLed = 0
endif
goto TestInt

Thank you very much!

Vic Chaney

AvionicsMaster1
- 24th January 2014, 23:49
It looks like RB0, RB1 and RB2 can have analog inputs where RC0 does not. I don't see in your program where you turn the analog functions off. This is only after a quick read of your program and the data sheet. Try turning them off first and if there is a setting to make them digital inputs, I'd try doing that also.

chaneyv4
- 25th January 2014, 01:23
That did it! My problem is solved!

Thank you so much. Your reply has ended a long period of aggravation, trying to figure this out.

I used a PIC18F252 for a similar purpose to what I am doing now, and it did not need this (probably due to a less robust set of A/D functions).

There are only a few small spots in the datasheet that cover this.

Thank you again!

Vic

AvionicsMaster1
- 25th January 2014, 18:23
Miracles do happen! I got something right! Please don't tell boss or wife.