unable to read the indual ports
Posted: Mon Apr 28, 2008 1:05 pm
in my following program I assign port A as the input and portB as the output, when I run the program I can control the outputs but I cannot scan my input ports, I dont know how to select the portA,0 when using the program the response only from the portA,4 but by pressing other ports of portA there is no response, pls tell me where am I making the mistake.
/* project name Micstation
date: 25.04.08
watch dog timer disabled
high speed ossilator enabled
low voltage programming disabled
*/
unsigned int OUTPUT_STATUS, COUNT1, COUNT2, COUNT3, COUNT4, COUNT5, COUNT6, COUNTER_STATUS;
unsigned int input;
char test_bit;
char oldinput;
void main() {
//STATUS = 0X03;
//PORTA = 0X05;
//PORTB = 0X06;
OUTPUT_STATUS = 0X21;
COUNT1 = 0X22;
COUNT2 = 0X23;
COUNTER_STATUS = 0X24;
COUNT3 = 0X25;
COUNT4 = 0X26;
COUNT5 = 0X27;
COUNT6 = 0X28;
test_bit = 0X29;
PORTA = 0X0;
TRISA = 0XFF;
PORTB = 0X0;
TRISB = 0X0;
PORTC = 0;
TRISC = 0;
PORTD = 0;
TRISD = 0;
OUTPUT_STATUS = 0;
input = PORTA;
oldinput = input;
while(1) {
//PORTC = 0xff;
//Delay_ms(1000);
asm {
BTFSS Status,3
nop
bsf portC,7 }
if (Button(&PORTA, 1, 1, 0)) {
test_bit = 1;
//PORTB = 0XD2;
}
else
PORTB = 0XD1;
if (test_bit && Button(&PORTA, 1, 1, 0)) {
PORTB = ~PORTB;
test_bit =0; }
}
}
/* project name Micstation
date: 25.04.08
watch dog timer disabled
high speed ossilator enabled
low voltage programming disabled
*/
unsigned int OUTPUT_STATUS, COUNT1, COUNT2, COUNT3, COUNT4, COUNT5, COUNT6, COUNTER_STATUS;
unsigned int input;
char test_bit;
char oldinput;
void main() {
//STATUS = 0X03;
//PORTA = 0X05;
//PORTB = 0X06;
OUTPUT_STATUS = 0X21;
COUNT1 = 0X22;
COUNT2 = 0X23;
COUNTER_STATUS = 0X24;
COUNT3 = 0X25;
COUNT4 = 0X26;
COUNT5 = 0X27;
COUNT6 = 0X28;
test_bit = 0X29;
PORTA = 0X0;
TRISA = 0XFF;
PORTB = 0X0;
TRISB = 0X0;
PORTC = 0;
TRISC = 0;
PORTD = 0;
TRISD = 0;
OUTPUT_STATUS = 0;
input = PORTA;
oldinput = input;
while(1) {
//PORTC = 0xff;
//Delay_ms(1000);
asm {
BTFSS Status,3
nop
bsf portC,7 }
if (Button(&PORTA, 1, 1, 0)) {
test_bit = 1;
//PORTB = 0XD2;
}
else
PORTB = 0XD1;
if (test_bit && Button(&PORTA, 1, 1, 0)) {
PORTB = ~PORTB;
test_bit =0; }
}
}