| Transmitting
an 8 bit byte of information is performed by the CommPortSendByte()
function. This function first checks to see if the
transmit register can be written to and then writes
the byte it. Notice that while it is waiting for the
TXIF bit to get set it is checking the framing and
overrun error bits.
Add this function to the serial.c file and also
don't forget to add the function prototype in the
serial.h file.
|
/*
------------------------------------------
// function: CommPortSendByte( unsigned tx )
// description: This function sends a byte
//
passed to it.
// ---------------------------------------*/
void CommPortSendByte( unsigned char
tx )
{
/* ------------------------------------
// Wait for the previous transmission
// to complete.
// ----------------------------------*/
while( !TXIF )
{
CommPortClearErrors();
}
TXREG = tx;
} |