stm32mp157 (discovery kit) usart3 not starting from A7
I am using stm32mp157d from stm32mp1 dk1 to work on an embedded project.
When I boot bare-metal from A7, I have no trouble to read and write to UART 4, however I run into a wall when I try to user UART 7 or USART3.
The HAL library works for UART4, so I do not believe that the problem lies there.
That been said, there seem to be a mismatch in the documents about the pins of USART3.
In the document Discovery kits with increased-frequency 800 MHz STM32MP157 MPUs (UM2637) It is stated that USART3 is at CN2, physical pin 8 for TX and pin 10 for RX (9 used for ground) with their in-code name B10 and B12 respectively.
In the document Datasheet - STM32MP157A/D under Table 8Alternate function AF0 to AF7, USART3_TX appears as PD8, PC10 , and PB10 USART3_RX appears as PD9, PC11, and PB11.
So far, I have tried to start USART3 without init any GPIO, trying port b8, b10 , b11 ,c10, c11, D8, D9. I tried those ports in low and high freq.
Please help me understand which ports do I need to assign as USART3, as currently nothing output nor input from port 8 and 10 of the GPIO pins at the discovery kit.
snippet of code from the GPIO init:
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOZ_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF8_USART3;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
snippet of code of UART init:
huart3.Instance = USART3;
huart3.Init.BaudRate = 115200;
huart3.Init.WordLength = UART_WORDLENGTH_8B;
huart3.Init.StopBits = UART_STOPBITS_1;
huart3.Init.Parity = UART_PARITY_NONE;
huart3.Init.Mode = UART_MODE_TX_RX;
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart3.Init.OverSampling = UART_OVERSAMPLING_16;
huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart3.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart3) != HAL_OK)
{
return -1;
}
if (HAL_UARTEx_SetTxFifoThreshold(&huart3, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
return -1;
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart3, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
return -1;
}
if (HAL_UARTEx_DisableFifoMode(&huart3) != HAL_OK)
{
return -1;
}
return 0;
