2018-09-22 01:36 PM
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?
2018-09-22 02:51 PM
>>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...