打印
[APM32E0]

APM32E030的串口速率上不到1Mbps

[复制链接]
40|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
涡流远见者|  楼主 | 2025-7-31 16:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
昨天晚上在做APM32E030R的开发时,把APM32E030的串口速率提到1Mbps无法正常通讯了。

大家有出现类似的情况吗?

我的初始化代码来自参考例程,我的在115200bps下是可以的。

void uart2_init(uint32_t band)
{
  GPIO_Config_T gpioConfig;
  USART_Config_T usartConfigStruct;
  /* Enable GPIO clock */
  RCM_EnableAHBPeriphClock(RCM_AHB_PERIPH_GPIOA);
  RCM_EnableAPB1PeriphClock(USART2);
  /* Connect PXx to USARTx_Tx */
  GPIO_ConfigPinAF(GPIOA, GPIO_PIN_SOURCE_2, GPIO_AF_PIN1);

  /* Connect PXx to USARTx_Rx */
  GPIO_ConfigPinAF(GPIOA, GPIO_PIN_SOURCE_3, GPIO_AF_PIN1);
  /* Configure USART Tx as alternate function push-pull */
  gpioConfig.mode = GPIO_MODE_AF;
  gpioConfig.pin = GPIO_PIN_2;
  gpioConfig.speed = GPIO_SPEED_50MHz;
  gpioConfig.outtype = GPIO_OUT_TYPE_PP;
  gpioConfig.pupd = GPIO_PUPD_PU;
  GPIO_Config(GPIOA, &gpioConfig);

    /* Configure USART Rx as input floating */
  gpioConfig.pin = GPIO_PIN_3;
  GPIO_Config(GPIOA, &gpioConfig);
  
  usartConfigStruct.baudRate = band;
  usartConfigStruct.mode     = USART_MODE_TX_RX;
  usartConfigStruct.hardwareFlowCtrl = USART_FLOW_CTRL_NONE;
  usartConfigStruct.parity   = USART_PARITY_NONE;
  usartConfigStruct.stopBits =  USART_STOP_BIT_1;
  usartConfigStruct.wordLength = USART_WORD_LEN_8B;
  USART_Config(USART2, &usartConfigStruct);
  
  /* Enable USART */
  USART_Enable(USART2);
}

void debug_uart_sendbyte(uint8_t dat)
{
  while (USART_ReadStatusFlag(USART2, USART_FLAG_TXBE) == RESET);
  USART_TxData(USART2, dat);
}




使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

4

主题

45

帖子

0

粉丝