stm32f070RBt6的串口3和其它串口冲突不能同时工作,stm32f070RBt6为64脚,TX:24脚PC4;RX :25脚, void USART3_Configuration(void)//´®¿Ú3³õʼ»¯º¯Êý { //NVIC_InitTypeDef NVIC_InitStructure; GPIO_InitTypeDef GPIO_InitStructure3; /* Enable GPIO TX/RX clock */ __HAL_RCC_GPIOC_CLK_ENABLE(); /* Enable USART3 clock */ __HAL_RCC_USART3_CLK_ENABLE(); /* * USART3_TX > PC4 , USART3_RX > PC5 */ GPIO_InitStructure3.Pin = GPIO_Pin_4|GPIO_Pin_5; GPIO_InitStructure3.Mode = GPIO_MODE_AF_PP; GPIO_InitStructure3.Pull = GPIO_NOPULL; GPIO_InitStructure3.Alternate = GPIO_AF_1; GPIO_InitStructure3.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOC, &GPIO_InitStructure3); /** * @brief UART Initialization */ UartHandle3.Instance = USART3; UartHandle3.Init.BaudRate = 115200; UartHandle3.Init.WordLength = UART_WORDLENGTH_8B; UartHandle3.Init.StopBits = UART_STOPBITS_1; UartHandle3.Init.Parity = UART_PARITY_NONE; UartHandle3.Init.HwFlowCtl = UART_HWCONTROL_NONE; UartHandle3.Init.Mode = UART_MODE_TX_RX; UartHandle3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; if(HAL_UART_DeInit(&UartHandle3) != HAL_OK) { Usart1Error_Handler(); } if(HAL_UART_Init(&UartHandle3) != HAL_OK) { Usart1Error_Handler(); } /*##3 Configure the NVIC for UART ########################################*/ /* NVIC for USART1 */ //HAL_NVIC_SetPriority(USART3_4_IRQn, 3, 1); //HAL_NVIC_EnableIRQ(USART3_4_IRQn); /* Enable USART1 Receive and Transmit interrupts */ __HAL_UART_ENABLE_IT(&UartHandle3,UART_IT_RXNE); __HAL_UART_ENABLE_IT(&UartHandle3,UART_IT_IDLE); /* Enable the USART1 */ __HAL_UART_ENABLE(&UartHandle3);//ʹÄÜ´®¿Ú1 } 要如何设置? |
评分
查看全部评分
用STM32F103时,IO中断9到15就是共用一个中断向量,从来没冲突过。
评分
查看全部评分
{
//NVIC_InitTypeDef NVIC_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure3;
/* Enable GPIO TX/RX clock */
__HAL_RCC_GPIOC_CLK_ENABLE();
/* Enable USART3 clock */
__HAL_RCC_USART3_CLK_ENABLE();
/*
* USART3_TX -> PC4 , USART3_RX -> PC5
*/
GPIO_InitStructure3.Pin = GPIO_Pin_4|GPIO_Pin_5;
GPIO_InitStructure3.Mode = GPIO_MODE_AF_PP;
GPIO_InitStructure3.Pull = GPIO_NOPULL;
GPIO_InitStructure3.Alternate = GPIO_AF_1;
GPIO_InitStructure3.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure3);
/**
* @brief UART Initialization
*/
UartHandle3.Instance = USART3;
UartHandle3.Init.BaudRate = 115200;
UartHandle3.Init.WordLength = UART_WORDLENGTH_8B;
UartHandle3.Init.StopBits = UART_STOPBITS_1;
UartHandle3.Init.Parity = UART_PARITY_NONE;
UartHandle3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
UartHandle3.Init.Mode = UART_MODE_TX_RX;
UartHandle3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if(HAL_UART_DeInit(&UartHandle3) != HAL_OK)
{
Usart1Error_Handler();
}
if(HAL_UART_Init(&UartHandle3) != HAL_OK)
{
Usart1Error_Handler();
}
/*##-3- Configure the NVIC for UART ########################################*/
/* NVIC for USART1 */
// HAL_NVIC_SetPriority(USART3_4_IRQn, 3, 1);
// HAL_NVIC_EnableIRQ(USART3_4_IRQn);
/* Enable USART1 Receive and Transmit interrupts */
__HAL_UART_ENABLE_IT(&UartHandle3,UART_IT_RXNE);
//__HAL_UART_ENABLE_IT(&UartHandle3,UART_IT_IDLE);
/* Enable the USART1 */
__HAL_UART_ENABLE(&UartHandle3);//ʹÄÜ´®¿Ú1
}
{
//NVIC_InitTypeDef NVIC_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure4;
/* Enable GPIO TX/RX clock */
__HAL_RCC_GPIOC_CLK_ENABLE();
/* Enable USART4 clock */
__HAL_RCC_USART4_CLK_ENABLE();
/*
* USART4_TX -> PC10 , USART4_RX -> PC11
*/
GPIO_InitStructure4.Pin = GPIO_Pin_10|GPIO_Pin_11;
GPIO_InitStructure4.Mode = GPIO_MODE_AF_PP;
GPIO_InitStructure4.Pull = GPIO_NOPULL;
GPIO_InitStructure4.Alternate = GPIO_AF_1;
GPIO_InitStructure4.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure4);
/**
* @brief UART Initialization
*/
UartHandle4.Instance = USART4;
UartHandle4.Init.BaudRate = 115200;
UartHandle4.Init.WordLength = UART_WORDLENGTH_8B;
UartHandle4.Init.StopBits = UART_STOPBITS_1;
UartHandle4.Init.Parity = UART_PARITY_NONE;
UartHandle4.Init.HwFlowCtl = UART_HWCONTROL_NONE;
UartHandle4.Init.Mode = UART_MODE_TX_RX;
UartHandle4.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if(HAL_UART_DeInit(&UartHandle4) != HAL_OK)
{
Usart1Error_Handler();
}
if(HAL_UART_Init(&UartHandle4) != HAL_OK)
{
Usart1Error_Handler();
}
/*##-3- Configure the NVIC for UART ########################################*/
/* NVIC for USART1 */
HAL_NVIC_SetPriority(USART3_4_IRQn, 3, 1);
HAL_NVIC_EnableIRQ(USART3_4_IRQn);
/* Enable USART1 Receive and Transmit interrupts */
__HAL_UART_ENABLE_IT(&UartHandle4,UART_IT_RXNE);
//__HAL_UART_ENABLE_IT(&UartHandle4,UART_IT_IDLE);
/* Enable the USART1 */
__HAL_UART_ENABLE(&UartHandle4);//ʹÄÜ´®¿Ú1
}
评分
查看全部评分
评分
查看全部评分