cancel
Showing results for 
Search instead for 
Did you mean: 

Bypassing UART

Abhishek Kumar
Associate III

I have a UART configured in DMA read mode:

/* task 1 code*/
uint8_t  dmaRXBuffer[1];
HAL_UART_Receive_DMA(&UART_DOWN_USB_TO_SERIAL, dmaRXBuffer, 1);
 
/* UART DMA receive complete ISR code*/
void HAL_UART_RxCpltCallback(UART_HandleTypeDef* huart) {
if (huart->Instance == UART8)  {
   xQueueSendToBackFromISR(queueXY, huart->pRxBuffPtr, NULL);
  }
}

so whenever it received a byte, it sends the data to a queue which is consumed by a RTOS task for its own functionality.

Now, at the same time without disturbing this functionality which resides in a task, what I also want is, whatever data is coming on this receive UART port should (without any waste of CPU cycle) be transmitted to another UART port on the mcu, how can I achieve this?

1 REPLY 1

>>without any waste of CPU cycle

A one byte DMA on the Rx is wasting a lot of cycles compared to an equivalent IRQ solution.

For an USART of the same or higher baud rate

USART1->TDR = *huart->pRxBuffPtr; // or ->DR for implementation sharing RDR/TDR

This will take several cycles, but pales to those you're burning wastefully elsewhere...

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..