The TI interface is pulled high by resisters, never driven high. The proper connection would use two i/o lines. They should be input at all times unless you are driving the line low: PIN = LOW TRIS = 0 (output) delay TRIS = 1 (input) -Adam Andrew Seddon wrote: > > Sorry for the large post but I have no website. > > Well there`s good news and bad news. First off I have kind of got the > interface routines working. I say that because it sometimes works and > sometimes dosn`t. When I program my TI-83+ to read a byte then spew it back > out everything works fine. However when I try to make two TI`s, a 83+ and a > TI-82 talk through the PIC it dosn`t work!! Dammned if I know whats up.. > Below is the code that I am using if anybody is interested or can find a bug > in it. > > BTW it`s in C2C but most of the custom function calls are self explanitary. > Sorry about the lack of comment. > > The calc variable is used as I have two calculators connected to one PIC, > both operating off the lower four bits of the A and B ports. The electrical > connection is just > > CALC 1 - WHITE - A0 + A2 > - RED - A1 + A3 > > CALC 2 - WHITE - B0 + B0 > - RED - B1 + B3 > > there are no resistors, diodes anyting, is that the problem?? > > Here`s the code. Some redundent code commented out, was used it testing. > > //RS232 settings > #pragma RS232_TXPORT RC > #pragma RS232_RXPORT RC > #pragma RS232_TXPIN 0 > #pragma RS232_RXPIN 1 > #pragma RS232_BAUD 19200 > > #pragma TURBO_MODE 1 > #pragma CLOCK_FREQ 50000000 > > char tris_a=255; > char tris_b=255; > > char bytetemp=0, bytetemp1=0; > char temp4=0; > > void sendDECNumber( char data ) > { > putchar( '0' + data/100 ); > putchar( '0' + (data%100)/10 ); > putchar( '0' + data%10 ); > } > > void sendHEXNumber( char data ) > { > //Send high nibble > if( (data>>4) > 9 ) > putchar( 'A' - 10 + (data>>4) ); > else > putchar( '0' + (data>>4) ); > //Send low nibble > if( (data&0x0F) > 9 ) > putchar( 'A' - 10 + (data&0x0F) ); > else > putchar( '0' + (data&0x0F) ); > } > > void printf( const char* text ) > { > char i = 0; > while( text[i] != 0 ) { > putchar( text[i++] ); > delay_ms(10); > } > } > > void output_white_high(char calc) > { > if (calc == 1) > { > set_bit(tris_a, 0); > set_tris_a(tris_a); > } > > if (calc == 2) > { > set_bit(tris_b, 0); > set_tris_b(tris_b); > } > delay_ms(2); > } > > void output_white_low(char calc) > { > if (calc == 1) > { > clear_bit(tris_a, 0); > set_tris_a(tris_a); > } > > if (calc == 2) > { > clear_bit(tris_b, 0); > set_tris_b(tris_b); > } > delay_ms(2); > } > > void output_red_high(char calc) > { > if (calc == 1) > { > set_bit(tris_a, 1); > set_tris_a(tris_a); > } > > if (calc == 2) > { > set_bit(tris_b, 1); > set_tris_b(tris_b); > } > delay_ms(2); > } > > void output_red_low(char calc) > { > if (calc == 1) > { > clear_bit(tris_a, 1); > set_tris_a(tris_a); > } > > if (calc == 2) > { > clear_bit(tris_b, 1); > set_tris_b(tris_b); > } > delay_ms(2); > } > > char input_white(char calc) > { > if(calc == 1) > { > if(input_pin_port_a(2)) return 1; > else return 0; > } > > if(calc == 2) > { > if(input_pin_port_b(2)) return 1; > else return 0; > } > delay_ms(2); > } > > char input_red(char calc) > { > if(calc == 1) > { > if(input_pin_port_a(3)) return 1; > else return 0; > } > > if(calc == 2) > { > if(input_pin_port_b(3)) return 1; > else return 0; > } > delay_ms(2); > } > > char get_byte(char calc) > { > char bitcount=0, tempbit=0; > while(bitcount < 8) > { > while ((input_red(calc) == 1) && (input_white(calc) == 1)){nop();} > //putchar('1'); > if (input_red(calc)==0) > { > output_white_low(calc); > while(input_red(calc)==0); > //putchar('2'); > bitcount=bitcount + 1; > output_white_high(calc); > delay_ms(5); > } > > if (input_red(calc)==1) > { > output_red_low(calc); > while(input_white(calc)==0); > //putchar('3'); > if (bitcount == 0) set_bit(tempbit, 0); > if (bitcount == 1) set_bit(tempbit, 1); > if (bitcount == 2) set_bit(tempbit, 2); > if (bitcount == 3) set_bit(tempbit, 3); > if (bitcount == 4) set_bit(tempbit, 4); > if (bitcount == 5) set_bit(tempbit, 5); > if (bitcount == 6) set_bit(tempbit, 6); > if (bitcount == 7) set_bit(tempbit, 7); > > bitcount=bitcount+1; > output_red_high(calc); > delay_ms(5); > } > } > > return tempbit; > } > > void transmit_high(char calc) > { > output_white_low(calc); > > while(input_red(calc)==1){nop();} > > output_white_high(calc); > > while(input_red(calc)==0){nop();} > > } > > void transmit_low(char calc) > { > output_red_low(calc); > > while(input_white(calc)==1){nop();} > > output_red_high(calc); > > while(input_white(calc)==0){nop();} > > } > > void send_byte(char byte, char calc) > { > > bytetemp=byte; > > while((input_red(calc)==0) || (input_white(calc)==0)){nop();} > delay_ms(2); > > asm{ > bank _bytetemp > mov w, _bytetemp > and w, #%00000001 > bank _bytetemp1 > mov _bytetemp1, w > } > if(bytetemp1==0) transmit_low(calc); > else transmit_high(calc); > > asm{ > bank _bytetemp > mov w, _bytetemp > and w, #%00000010 > bank _bytetemp1 > mov _bytetemp1, w > } > if(bytetemp1==0) transmit_low(calc); > else transmit_high(calc); > > asm{ > bank _bytetemp > mov w, _bytetemp > and w, #%00000100 > bank _bytetemp1 > mov _bytetemp1, w > } > if(bytetemp1==0) transmit_low(calc); > else transmit_high(calc); > > asm{ > bank _bytetemp > mov w, _bytetemp > and w, #%00001000 > bank _bytetemp1 > mov _bytetemp1, w > } > if(bytetemp1==0) transmit_low(calc); > else transmit_high(calc); > > asm{ > bank _bytetemp > mov w, _bytetemp > and w, #%00010000 > bank _bytetemp1 > mov _bytetemp1, w > } > if(bytetemp1==0) transmit_low(calc); > else transmit_high(calc); > > asm{ > bank _bytetemp > mov w, _bytetemp > and w, #%00100000 > bank _bytetemp1 > mov _bytetemp1, w > } > if(bytetemp1==0) transmit_low(calc); > else transmit_high(calc); > > asm{ > bank _bytetemp > mov w, _bytetemp > and w, #%01000000 > bank _bytetemp1 > mov _bytetemp1, w > } > if(bytetemp1==0) transmit_low(calc); > else transmit_high(calc); > > asm{ > bank _bytetemp > mov w, _bytetemp > and w, #%10000000 > bank _bytetemp1 > mov _bytetemp1, w > } > if(bytetemp1==0) transmit_low(calc); > else transmit_high(calc); > } > > main() > { > set_tris_a(255); > set_tris_b(255); > set_tris_c(11111110b); > > output_port_a(0); > output_port_b(0); > output_port_c(0); > > printf("\n\r START \n\r"); > > //while(1){ > //temp4=get_byte(1); > //sendHEXNumber(temp4); > //printf("\n\r"); > //} > > while(1){ > if(input_red(1)==0) {temp4=get_byte(1); send_byte(temp4, 2); > sendHEXNumber(temp4);} > if(input_white(1)==0) {temp4=get_byte(1); send_byte(temp4, 2); > sendHEXNumber(temp4);} > if(input_red(2)==0) {temp4=get_byte(2); send_byte(temp4, 1); > sendHEXNumber(temp4);} > if(input_white(2)==0) {temp4=get_byte(2); send_byte(temp4, > 1);sendHEXNumber(temp4);} > } > > } > > ________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com