昨天晚上在做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);
}
|