Tool/software:
Our device has RS485 communication enabled and it's working okay, but I want to switch to be only interrupt driven communication so the processor doesn't have to sit and loop while waiting for characters to be transmitted.
This is the code to enable one of the serial ports:
ROM_IntEnable(INT_UART1);
ROM_UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT);
Do I need to add UART_INT_TX, as below?
ROM_UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT | UART_INT_TX);
I found this command in sample code:
MAP_UARTFIFOLevelSet(g_ui32Base, UART_FIFO_TX1_8, UART_FIFO_RX1_8);
Does that mean an interrupt will be generated when there is one character left in the transmit buffer?
Is that what I use to trigger an interrupt telling me it's time to put more characters in the transmit buffer?
Here are the first lines in our interrupt handler:
UARTHB_Status = ROM_UARTIntStatus(UART1_BASE, true); // Get the interrrupt status
ROM_UARTIntClear(UART1_BASE, UARTHB_Status); // Clear the asserted interrupts
Do these statements clear all interrupts, or will I need to add something else to clear a transmit interrupt?
This is the code I'm using to fill the output buffer. Feel free to comment.
for( i = 0 ; i < 300; i++) // Fill FIFO buffer. NOTE: The FIFO buffer was never enabled until v2.27.
{
if(must_resend_char_HB)
global_char_HB = character_to_resend_HB;
else
global_char_HB = get_from_output_buffer_HB();
if ( UARTCharPutNonBlocking(UartPort_HB, global_char_HB) == false ) // character did not go in FIFO, must try again. UART1_BASE
{
must_resend_char_HB = true;
character_to_resend_HB = global_char_HB;
break;
}
else
{
must_resend_char_HB = false;
}
if(out_wrptr_HB == out_rdptr_HB)
{
Host_1_HB_transmission_finished = true;
characters_to_send_HB = false;
break;
}
}
Thanks very much.