如下是打开这个寄存器的具体截图,可以看到IDLE位初始化不一样;第一张没有对勾的是我的初始化后的,第二张是例程的:
如下是我的初始化代码:
void USART_Config(void)
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_IOMUX,ENABLE); //??IOMux??
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
USART1_TX_IO_CLK_EN();
USART1_RX_IO_CLK_EN();
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = DEBUG_USART_TX_GPIO_PIN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_IOMUX_ChangePin(IOMUX_PIN5,IOMUX_PB5_SEL_PA3);// SOP8 PIN7(NRST)PA0 IO IOMUX_NRST_SEL_NRST IOMUX_NRST_SEL_PA0
GPIO_Init(DEBUG_USART_TX_GPIO_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(DEBUG_USART_TX_GPIO_PORT,DEBUG_USART_TX_GPIO_PIN,GPIO_AF_1);
GPIO_InitStructure.GPIO_Pin = DEBUG_USART_RX_GPIO_PIN;
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_Init(DEBUG_USART_RX_GPIO_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(DEBUG_USART_RX_GPIO_PORT, DEBUG_USART_RX_GPIO_PIN,GPIO_AF_1);
DEBUG_USART_APBxClkCmd(DEBUG_USART_CLK, ENABLE);
USART_InitStructure.USART_BaudRate = DEBUG_USART_BAUDRATE;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No ;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(DEBUG_USARTx, &USART_InitStructure);
USART_SWAPPinCmd(USART1, ENABLE);
USART_Cmd(DEBUG_USARTx, ENABLE);
USART_ITConfig(DEBUG_USARTx, USART_IT_RXNE, ENABLE);
NVIC_Configuration();
}
|