#include "p18F4620.h"
#pragma config XINST=OFF
#pragma config OSC=INTIO67
void main (void)
{
char tecla;
TRISC=0xAB;
PORTC=0x40;
Nop();
if (PORTCbits.RC5==1)
{
tecla=2;
}
if (PORTCbits.RC3==1)
{
tecla=0;
}
if (PORTCbits.RC1==1)
{
tecla=8;
}
if (PORTCbits.RC0==1)
{
tecla=5;
}
}
The problem is that with the register PORTC changes its value where it has their inputs from 0 to 1 seemingly as it feels like, despite the inputs being 0 all the time and having 0 measuring it with a polimeter.
I've also checked that if I kept measuring the input and GND continuosly the changes on this input are done right (it doesn't change as long as I don't make it to change). Anyone has an idea what this would be equivalent to?
When using single pins you'll find that " LATCbits.LATC2 = 1;", instead of "PORTC = 0x40;", will be more reliable.... In the datasheet look for "READ/MODIFY/WRITE"