#define UART1_TX_BUFFER_LENGTH 10
uint8_t debug_do_status_tx_100ms_timer = 0;
char uart1_tx_buffer[UART1_TX_BUFFER_LENGTH];
uint8_t uart1_num_of_bytes_to_tx = 0;
uint8_t uart1_next_tx_byte = 0;
//***** 100mS HEARTBEAT TIMER *****
debug_do_status_tx_100ms_timer++;
static char *p_buffer;
//----- DEBUG STATUS TX ON UART 1 -----
if (debug_do_status_tx_100ms_timer >= 20)
{
debug_do_status_tx_100ms_timer = 0;
p_buffer = &uart1_tx_buffer[0];
*p_buffer++ = 'V';
p_buffer = convert_uint16_to_char_ascii((uint16_t)OUR_FIRMWARE_REVISION, p_buffer, &uart1_tx_buffer[(UART1_TX_BUFFER_LENGTH - 1)]);
*p_buffer++ = ' ';
*p_buffer++ = '\r';
*p_buffer++ = '\n';
uart1_num_of_bytes_to_tx = (BYTE)(p_buffer - &uart1_tx_buffer[0]);
uart1_next_tx_byte = 0;
}
//TX NEXT BYTE
if (uart1_num_of_bytes_to_tx > 0)
{
if (TXSTAbits.TRMT)
TXREG = uart1_tx_buffer[uart1_next_tx_byte++];
if (uart1_next_tx_byte >= uart1_num_of_bytes_to_tx)
uart1_num_of_bytes_to_tx = 0;
}
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.