Mehmood Ahmed
New Member
this section of code has been written for getting data from tristate buffer IC using multiplexing technique but it's not working. compiler being used is HITECH C whereas I wrote same section of code using CCS C compiler and it works fine. In that version I used its library functions. I am putting here both the versions. Please suggest what wrong I am doing with HITECH C version of code. Thanks
Code:
HITECH C version
unsigned char getdata(unsigned char address)
{
unsigned char x;
switch(address)
{
case 0x1:
RA0 = 0;
TRISA0 = 0;
TRISB = 0xff;
x = PORTB;
RA0 = 1;
TRISA0 = 1;
break;
case 0x2:
RA1 = 0;
TRISA1 = 0;
TRISB = 0xff;
x = PORTB;
RA1 = 1;
TRISA1 = 1;
}
return x;
}
CCS C version
unsigned char getdata(unsigned char address)
{
unsigned char x;
switch(address)
{
case 0x1:
set_tris_b(0xff);
output_bit(PIN_A0,0);
x = input_b();
output_bit(PIN_A0,1);
break;
case 0x2:
set_tris_b(0xff);
output_bit(PIN_A1,0);
x = input_b();
output_bit(PIN_A1,1);
break;
}
return x;
}
Last edited: