What is the proper way to use UART with interrupts on DM355?
Here is how I have implemented UART2:
interrupt()
{
// first, check if we need to transmit anything
if ( LSR & THRE) // TX fifo empty
{
copy_16_bytes_from_buffer_to_THR;
}
else
{
disable_THR_EMPTY_interrupts_but_keep_all_other_enabled;
}
// now, let's check if we received anything
while ( LSR & DR) // RX fifo has data
{
copy_byte_from_RBR_to_buffer;
}
}
transmit_bytes_function() // function is called when bytes need to be transmitted
{
copy_data_to_buffer; // copy data to circular buffer
if (THR_EMPTY_interrupt_disabled)
{
enable_THR_EMPTY_interrupt_and_all_others;
}
}
During intensive communication the driver gets into a state where THR FIFO interrupt is enabled, the THR FIFO is empty but the interrupt does not fire.
What could be the problem?