#include #include "sci.h" /* Routines for initialisation and use of the SCI * for the PIC processor. */ /* other options: * frame errors */ void sci_Init(void) { BRGH = 0; /* low baud rate */ SPBRG = 51; /* set the baud rate */ SYNC = 0; /* asynchronous */ SPEN = 1; /* enable serial port pins */ CREN = 1; /* enable reception */ SREN = 0; /* no effect */ TXIE = 0; /* disable tx interrupts */ RCIE = 0; /* disable rx interrupts */ TX9 = 0; /* 8-bit transmission */ RX9 = 0; /* 8-bit reception */ TXEN = 1; /* enable the transmitter */ } void sci_PutByte(unsigned char byte) { while(!TXIF) /* set when register is empty */ continue; TXREG = byte; return; } unsigned char sci_GetByte(void) { while(!RCIF) /* set when register is not empty */ continue; return RCREG; /* RXD9 and FERR are gone now */ }