Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. U1MODE = 0;                 // clear mode register
  2. U1MODEbits.BRGH = 1;        // use high precision baud generator
  3. U1BRG = 85;                 // (FCY/(4*baud))-1
  4. U1STA = 0;                  // clear status register
  5. U1MODEbits.UARTEN = 1;      // enable the UART RX
  6. IFS0bits.U1RXIF = 0;        // clear the receive flag
  7. ...
  8. while(U1STAbits.URXDA == 0);    // wait for data to arrive
  9. c=U1RXREG;          // put data in char c
  10. ...
  11. if (U1STAbits.UTXEN ==0)
  12.     U1STAbits.UTXEN = 1;    // enable UART TX
  13. while(U1STAbits.UTXBF == 1);    // if buffer is full, wait
  14. U1TXREG = c;            // send a character