STM32f070RBt6的串口3和其它串口冲突不能同时工作,stm32f070RBt6为64脚,TX:24脚PC4;RX :25脚,
void USART3_Configura
tion(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就是共用一个中断向量,从来没冲突过。
一周热门 更多>