在这里我当时有个疑问,现在我们都知道我的数据乱码是因为串口在识别起始位的时候出现了问题,可是GD32F4的串口有两种模式通过OSB=0或=1来设置,那么这两种模式起始位都是这样识别的吗?于是我再次实验:
在gd32f4xx_usart.c有配置OSB位的函数,如下:
/*!
\brief configure sample bit method
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] obsm: sample bit
only one parameter can be selected which is shown as below:
\arg USART_OSB_1bit: 1 bit
\arg USART_OSB_3bit: 3 bits
\param[out] none
\retval none
*/
void usart_sample_bit_config(uint32_t usart_periph, uint32_t obsm)
{
USART_CTL2(usart_periph) &= ~(USART_CTL2_OSB);
USART_CTL2(usart_periph) |= obsm;
}
|