Not able to use UART1 in STM32MP135F-DK board
Hi all,
I own a STM32MP135F-DK board and started to write a simple firmware on it based on RTX threads.
I'd like to use USART1 port as simple terminal interface with the board.
I chose USART1 cause it is present on CN8 connector (RX + TX) and cause the UART8 presents only TX pin.
The code I wrote is:
void MX_USART1_UART_Init(void)
{
huart1.Instance = USART1;
huart1.Init.BaudRate = 9600;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
ASSERT(false);
}
}
and
if (uartHandle->Instance == USART1)
{
/* USER CODE BEGIN USART1_MspInit 0 */
/* USER CODE END USART1_MspInit 0 */
/* USART1 clock enable */
__HAL_RCC_USART1_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
/**USART1 GPIO Configuration
PC2 ------> USART1_RTS
PC0 ------> USART1_TX
PB0 ------> USART1_RX
*/
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF4_USART1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USART3 interrupt Init */
GIC_SetPriority(USART1_IRQn, 0);
GIC_EnableIRQ(USART1_IRQn);
/* USER CODE BEGIN USART1_MspInit 1 */
/* USER CODE END USART1_MspInit 1 */
}
I'm wondering if this code is correct cause, connecting to the CN8 pins a 232-USB FTDI232 converter I see nothing on the terminal running on Windows.
If I comment out the GIC_EnableIRQ() lines the firmware continue to run (without any serial output): I see the firmware is alive cause a task that blinks red and blue LEDS.
If I leave the IRQ (and I transmit something) the LEDs task freeze and if I press pause IDE button I almost always land in the IRQ_EndOfInterrupt() function (or nearby - irqarmv7a.S), with irqn=70 (USART1_IRQn).
If I try with UART8 I have the same behaviors but irqn=116 (UART8_IRQn).
Any idea, please?
