cancel
Showing results for 
Search instead for 
Did you mean: 

LL UART Interrupt

chriskuku
Senior II

Where can I find a complete compilation of the LL Api, especially what USART handling is concerned?

I'm trying to implement (with FreeRTOS underlying) a ring buffer driven I/O system to read from and write to UARTs.

Do I understand it right? There is one global UART ISR, where receive data available and transmitter empty interrupts are handled? When there is no data to be sent, TXEmpty IR should be disabled, right? How do I disable it?

Receiving characters and putting them into the input ring buffer works. But writing to the transmitter - I'm trying to implement a simple read/echo functionality on the same UART - doesn't seem to work.

This is my ISR:

void USART1_IRQHandler(void)
{
  /* USER CODE BEGIN USART1_IRQn 0 */
	  /* Check RXNE flag value in SR register */
		  if(LL_USART_IsActiveFlag_RXNE(USART1) && LL_USART_IsEnabledIT_RXNE(USART1)) {
		    /* RXNE flag will be cleared by reading of DR register (done in call) */
		    /* Call function in charge of handling Character reception */
		    USART_CharReception_Callback();
		  }
  /* USER CODE END USART1_IRQn 0 */
  /* USER CODE BEGIN USART1_IRQn 1 */
 
		  else if(LL_USART_IsActiveFlag_TXE(USART1) && LL_USART_IsEnabledIT_TXE(USART1)) {
			    
			     USART_TxEmpty_Callback();
		}
  /* USER CODE END USART1_IRQn 1 */
}
/* USER CODE BEGIN 4 */
void USART_CharReception_Callback()
{ 
    uart1_in_head++;
    if(uart1_in_head == QUEUE_LEN)
    	uart1_in_head=0;
    uart1_in_queue[uart1_in_head] = LL_USART_ReceiveData8(USART1);
}
 
void USART_TxEmpty_Callback() {
	if(uart1_out_tail != uart1_out_head){
	  uart1_out_tail++;
	  if(uart1_out_tail == QUEUE_LEN)
			   		uart1_out_tail=0;
	   LL_USART_TransmitData8(USART1,uart1_out_queue[uart1_out_tail]);  
	}
}

0 REPLIES 0