/* IMPORTANT: I don't know if it's necessary, but I put 10k resistors on * the transmit and receive pins of the pic, just to be safe, and it works fine. */ /* PIC16F84 * .-----------. * -|RA2 RA1|- TRANSMIT white * -|RA3 RA0|- * -|RA4 OSC1|- XT CLOCK pin1, 27pF to GND * PUSH BUTTON -|MCLR OSC2|- XT CLOCK pin2, 27pF to GND * GND -|Vss Vdd|- +5v * orange RECEIVE -|RB0 RB7|- * -|RB1 RB6|- * -|RB2 RB5|- * -|RB3 RB4|- * '-----------' * * PUSH BUTTON = PIN - BUTTON - GND * PIN - 10k - +5v */ /* rs232 interface (serial port communications) without a level converter. * Therefore microcontroller pins are connected DIRECTLY to the serial cable. * Therefore inverted (from standard) logic is used. * * PIC PIN18 PORTA1 - TRANSMIT (receive at PC end of serial cable) white * PIC PIN06 PORTB0 - RECEIVE (transmit at PC end of serial cable) orange */ /* looking head on at the female connector of a serial mouse coard: * i.e. the end that plugs into your pc * * 5 4 3 2 1 = blue null orange white null * 9 8 7 6 = null null yellow null * * the following are loose wires on the other end of the coard. * i.e. where it would have been soldered to the mouse circuit board. * * 5 = blue = gnd = GND * 3 = orange = td = PIC PIN06 PORTB0 * 2 = white = rd = PIC PIN18 PORTA1 * 7 = yellow = rts = unused */ #include #include "rs232.c" __CONFIG(WDTDIS & XT & UNPROTECT); main(void) { TRISA = 0b00000000; TRISB = 0b00000001; PORTA = 0; PORTB = 0; rs232_initialize(); rs232_send_string("Hello: "); for (;;) { rs232_echo_char(); } }