STM32F107vct6关于UART1引脚复用及重映射
时间:10-02
整理:3721RD
点击:
大家好!小弟在调试RS485通讯时,需要使用UART1串口,引脚是PB6、PB7,需要复用及重映射,部分程序如下,为什么不通呢?
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable GPIO clock */
RCC_APB2PeriphClockCmd(Modbus_COM_TX_GPIO_CLK | Modbus_COM_RX_GPIO_CLK, ENABLE);
RCC_APB2PeriphClockCmd(Modbus_COM_CLK, ENABLE);//
/*UART1 I/O口重映射开启 */
GPIO_PinRemapConfig(GPIO_Remap_USART1,ENABLE); //
/* Configure the NVIC Preemption Priority Bits */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
/* Enable the USARTy Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = Modbus_COM_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = ISR_PRIORITY_MODBUS;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable GPIO clock */
RCC_APB2PeriphClockCmd(Modbus_COM_TX_GPIO_CLK | Modbus_COM_RX_GPIO_CLK, ENABLE);
RCC_APB2PeriphClockCmd(Modbus_COM_CLK, ENABLE);//
/*UART1 I/O口重映射开启 */
GPIO_PinRemapConfig(GPIO_Remap_USART1,ENABLE); //
/* Configure the NVIC Preemption Priority Bits */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
/* Enable the USARTy Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = Modbus_COM_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = ISR_PRIORITY_MODBUS;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
有没有哪位大侠知道啊,谢谢