//////////////////////////////////////////////////////////////////////////////////////////// // File: serio.c // This code is provided by Dr. Robert Reese. // We thank him for the use of it. // // //////////////////////////////////////////////////////////////////////////////////////////// // standard non-interrupt driven serial IO subroutines // return 8 bit char from serial port char getch () { // wait until data available while (!RCIF){ // ok to wait forever for input // so clear watchdog timer asm("clrwdt"); }; return(RCREG); } // send 8 bit char to serial port void putch (char c) { // wait until transmit reg empty while (!TXIF){ asm("clrwdt"); }; TXREG = c; asm("clrwdt"); } void pcrlf () { putch(0x0a); //line feed putch(0x0d); //carriage return } // needed by scanf library call, // get character and echo unsigned char getche (void){ unsigned char c; c = getch(); putch(c); return(c); }