UART via DMA remains busy
Hello
I am currently working on a project needing UART via DMA, however when trying to transmit something via this UART nothing is received on the receiving end and the UART remains in HAL_UART_STATE_BUSY_TX.
I am also making use of ARM TrustZone.
USART1 is set to Non-Secure and linked to GPDMA1 Channel 3 in Standard Request mode (all default settings, source data address increment is enabled, memory to peripheral direction) also Non-Secure.
Relevant interrupts and callbacks seem to not get triggered, however it is not clear to me why, I tested this via setting breakpoints in the relevant functions.
From what I understand UART_InitCallbacksToDefault() should make it so HAL_UART_TxCpltCallback() is called when the relevant interrupt is triggered, but as mentioned above this simply does not occur so this makes me think I am simply missing some information.
Board used: STM32H573I-DK
All developments and configurations are done via the STMCubeIDE.
Relevant Code:
in main.c:
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* GTZC initialisation */
MX_GTZC_NS_Init();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_GPDMA1_Init();
MX_RTC_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
HAL_DMA_Init(&handle_GPDMA1_Channel3);
HAL_UART_Init(&huart1);
UART_InitCallbacksToDefault(&huart1);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
uint8_t in[512] = "test\r\n";
__enable_irq();
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_UART_Transmit_DMA(&huart1, &in, strlen(in));
HAL_Delay(1000);
//this function is not found, should normally be called through interrupt
//UART_DMATransmitCplt(&handle_GPDMA1_Channel3);
}
/* USER CODE END 3 */
}
in stm32h5xx_it.c
/* USER CODE BEGIN 1 */
void XferCpltCallback(void){
HAL_DMA_IRQHandler(&handle_GPDMA1_Channel3);
}
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart){
HAL_UART_IRQHandler(huart);
}
/**
* @brief DMA UART transmit process complete callback.
* @PAram hdma DMA handle.
* @retval None
*/
static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma)
{
UART_HandleTypeDef *huart = (UART_HandleTypeDef *)(hdma->Parent);
/* Check if DMA in circular mode */
if (hdma->Mode != DMA_LINKEDLIST_CIRCULAR)
{
huart->TxXferCount = 0U;
/* Enable the UART Transmit Complete Interrupt */
ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_TCIE);
}
/* DMA Circular mode */
else
{
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
/*Call registered Tx complete callback*/
huart->TxCpltCallback(huart);
#else
/*Call legacy weak Tx complete callback*/
HAL_UART_TxCpltCallback(huart);
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
}
}
/* USER CODE END 1 */
edit: added code tags.
