本帖最后由 天山狐狸 于 2016-1-28 22:07 编辑
如题,我使用了407的6个串口,用外设库初始化的,但是现在1通,3、6不通,2、4、5还没有测试。
代码如下,串口1、3、6的代码基本相同,只是USARTx不通而已。6个串口的管脚分配是软件STM32CubeMX生成的。
[mw_shl_code=applescript,true]void USART1_Init(uint32_t BaudRate)
{
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = 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(USART1, &USART_InitStructure);//初始化串口
USART_Cmd(USART1, ENABLE);//使能串口
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);//开相关中断
}
void USART3_Init(uint32_t BaudRate)
{
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = 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(USART3, &USART_InitStructure);//初始化串口
USART_Cmd(USART3, ENABLE);//使能串口
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);//开相关中断
}[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
这个是正确的
我上面的管脚、时钟等配置正确吗
一周热门 更多>