/* 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 * .-----------. * TRANSMIT white -|RA2 RA1|- * RECEIVE orange -|RA3 RA0|- * -|RA4 OSC1|- XT CLOCK pin1, 27pF to GND * PUSH BUTTON -|MCLR OSC2|- XT CLOCK pin2, 27pF to GND * GND -|Vss Vdd|- +5v * LCD D4 -|RB0 RB7|- ICSP * LCD D5 -|RB1 RB6|- ICSP * LCD D6 -|RB2 RB5|- LCD EN * LCD D7 -|RB3 RB4|- LCD RS * '-----------' * * 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 PIN01 PORTA2 - TRANSMIT (receive at PC end of serial cable) white * PIC PIN02 PORTA3 - 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 = PC_td = PIC PIN02 PORTA3 * 2 = white = PC_rd = PIC PIN01 PORTA2 * 7 = yellow = rts = unused */ #include #include "delay.c" #include "lcd.c" #include "rs232.c" __CONFIG(WDTDIS & XT & UNPROTECT); main(void) { unsigned int i = 0; unsigned char c; TRISA = 0b00001000; TRISB = 0b00000000; rs232_initialize(); lcd_initialize(); rs232_send_string("Hello: "); for (i=0;i<2;i++) { rs232_echo_char(); } lcd_draw_logo(); for (i=0;i<2;i++) { c = rs232_echo_char(); rs232_send_char(c); } lcd_clear_and_home(); for (i=0;i<2;i++) { c = rs232_echo_char(); lcd_write_char(c); } }