[问题] STM32h743 usart 调适问题

楼主: redluna (Occlumen)   2019-10-01 12:50:07
使用 cubemx/cubeIDE
之前在 stm32 f429 有做过类似的 work 有成功
但不太确定自己漏掉什么
用 minicom/CoolTerm 接从板子过来的讯号
设定 115200 8N1,PC 端一点东西都没有但切成 57600 会有乱码
有将 HSE_VALUE 调到过 8M hz 也没有成功
接 PC usb 的电源(应该是 5v)
请问我还有哪些地方需要检查或是做错了呢?
感谢大大回复
以下是 config code
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)
{
Error_Handler();
}
if (HAL_UARTEx_SetTxFifoThreshold(&huart3, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart3, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_DisableFifoMode(&huart3) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART3_Init 2 */
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Pin = STLINK_RX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
/* UART RX GPIO pin configuration */
GPIO_InitStruct.Pin = STLINK_TX_Pin;
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
作者: god145145   2019-10-01 17:38:00
先勾示波器看看
作者: suninrain (低潮)   2019-10-02 14:48:00
同意楼上~USART interface characteristics都有符合吗?Output speed is set to OSPEEDRy[1:0] = 10...那串~
楼主: redluna (Occlumen)   2019-10-02 23:13:00
好的我试试看
作者: suninrain (低潮)   2019-10-14 17:17:00
可以考虑把UART吃的频率output出来看看是不是有符合你的需求~因为后面设定都OK的话也有可能是他用的频率不是预期的~

Links booklink

Contact Us: admin [ a t ] ucptt.com