Page 1 of 1

problem with inputs on the 16F876A

Posted: Thu Jul 06, 2006 7:51 pm
by Raven
Hi, my name is Steve... I had been running an LCD program with the 16F84A, but eventually my program was too long and I needed to upgrade to a larger chip. I've been trying to use the 16F876A, but it seems the inputs do not work. The LCD routines work fine though. I ditched that program for a while and tried a very simple program just to get the inputs working. It worked fine with the other chip but not with this one. Here is the program...

#include <system.h>
void main (void)
{
set_tris_a (0xff);
set_tris_b (0x00);
while (1)
{
if (input_pin_port_a(0))
{
output_high_port_b(0);
}
else
{
output_low_port_b(0);
}
if (input_pin_port_a(1))
{
output_high_port_b(1);
}
else
{
output_low_port_b(1);
}
if (input_pin_port_a(2))
{
output_high_port_b(2);
}
else
{
output_low_port_b(2);
}
if (input_pin_port_a(3))
{
output_high_port_b(3);
}
else
{
output_low_port_b(3);
}
if (input_pin_port_a(4))
{
output_high_port_b(4);
}
else
{output_low_port_b(4);
}
if (input_pin_port_a(5))
{
output_high_port_b(5);
}
else
{output_low_port_b(5);
}
if (input_pin_port_a(6))
{
output_high_port_b(6);
}
else
{output_low_port_b(6);
}
if (input_pin_port_a(7))
{
output_high_port_b(7);
}
else
{output_low_port_b(7);
}
}
}


For some reason, pin #4 works, but none of the others do. When I push the inputs on port A(except for 4), none of the port B outputs light up. What could be causing these inputs to not be read?
Thanks

Posted: Fri Jul 07, 2006 9:12 am
by Ian
Have you turned the analogue ports off?

the 16F87X devices have analogue inputs on Port A which are on by default and need turning off for digital input.

Try adding an ADCON line to the start of your program to turn the ADC lines off e.g.:

adcon1 = 0x07;