cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U575 - UART4 interrupts stop working when USART1 is initialized on VDDIO2 power domain at 1.8V

PraneethCh
Visitor

Hi there!

I have two UART devices connected to STM32U575 that run at 1.8 and 3.3V and 115200 baud rate. I am trying to get USART1 working on STM32U575 on PG9 (TX) and PG10(RX) that uses VDDIO2 reference 1.8V and UART4 on PA1(RX) and PA0(TX) that uses main VDD 3.3V as reference voltage.

I have an LDO that uses 3.3 to get 1.8V and its enable pin (pulled LOW and disabled by default) is controlled by STM32U575 GPIO - PE4, so controlling the timing of 1.8V is possible.

Problem: After enabling 1v8 power and initializing USART1, the UART4 interrupts stop working but UART4 is able to still print. However, if I enable 1v8 power and I don't call the function MX_USART1_UART_Init(), UART4 interrupts works as expected.

I've tried enabling the VDDIO2 before initializing the USART1 but no luck. Below is the code that shows this behavior. 

void console_thread_entry(void *argument) {
	char tRxedChar;

	HAL_UART_Transmit(&huart4, (uint8_t *)"Hello!\r\n", strlen("Hello!\r\n"), 100);
	HAL_PWREx_DisableVddIO2();
	__HAL_RCC_GPIOG_CLK_DISABLE();

	HAL_GPIO_WritePin(nRF9151_ON_OFF_GPIO_Port, nRF9151_ON_OFF_Pin, GPIO_PIN_SET);
	HAL_Delay(5000);
	HAL_GPIO_WritePin(nRF9151_VDD_GPIO_ON_OFF_GPIO_Port, nRF9151_VDD_GPIO_ON_OFF_Pin, GPIO_PIN_SET);
	HAL_Delay(1000);

	// Enable VDDIO2 in software
	HAL_PWREx_EnableVddIO2();
	HAL_Delay(100); // Small delay to stabilize

	// Enable IO2 Voltage Monitoring
	PWR->SVMCR |= PWR_SVMCR_IO2VMEN;

	// Remove isolation on PG[15:2]
	PWR->SVMCR |= PWR_SVMCR_IO2SV;

	HAL_Delay(100);

	__HAL_RCC_GPIOG_CLK_ENABLE();

	HAL_Delay(100);

        /* Problematic line */
	MX_USART1_UART_Init();

        /* UART4 interrupts works only if USART1 is not initialized */
	HAL_UART_Receive_IT(&huart4, (uint8_t*)&c, 1);
	HAL_UART_Receive_IT(&huart1, (uint8_t*)&c2, 1);

        /* This line works whether USART1 is initialized or not */
	HAL_UART_Transmit(&huart4, (uint8_t *)"Hello again!\r\n", strlen("Hello again!\r\n"), 100);
	/* Infinite loop */
	for(;;) {
		/* Just echo back */
		if(xQueueReceive(uart_queueHandle, &tRxedChar, portMAX_DELAY) == pdPASS) {
			console_out("%c", tRxedChar);
		}
		osDelay(1);
	}
}

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
	BaseType_t xHigherPriorityTaskWoken = pdFALSE;

	if(huart->Instance == UART4) {
		HAL_UART_Receive_IT(&huart4, (uint8_t*)&c, 1);
		/* forward the character to cell UART queue */
		xQueueSendToBackFromISR(uart_queueHandle, (void *)&c, &xHigherPriorityTaskWoken);
		/* Wake-up on any activity on console */
		if (xHigherPriorityTaskWoken) {
				portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
		}
	} else if (huart->Instance == USART1) {
		HAL_UART_Receive_IT(&huart1, (uint8_t*)&c2, 1);
		/* forward the character to cell UART queue */
		xQueueSendToBackFromISR(uart_queueHandle, (void *)&c2, &xHigherPriorityTaskWoken);
		/* Wake-up on any activity on console */
		if (xHigherPriorityTaskWoken) {
				portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
		}
	}
}

Can USART1 run on 1.8V and the same time UART4 run on 3.3V? Is it possible that there is a bug somewhere in the drivers or am I missing any steps? I am really hoping to get these both UARTs to work at the same time and be able to talk to two different devices at 1.8 and 3.3 levels respectively.

Appreciate the help!

Thank you! 

1 REPLY 1

You have race conditions in HAL_UART_RxCpltCallback(), handler also not aware of enablement.

Might have a interrupt storm on the UARTs, check UART status registers, and NVIC state

What code manages PE4?

Why the dance with GPIOG / VDDIO2, the Disable / Enable

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