鄙人调试F429的UART4时遇到的问题,可以发送数据,但是不能接收数据,进不了接收中断,图片是调试时寄存器截图,希望知情的大大指点一二,剁碎! 代码如下:
[mw_shl_code=c,true]void Uart4_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource0,GPIO_AF_UART4);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource1,GPIO_AF_UART4);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_Init(GPIOA, &GPIO_InitStructure);//PA8??????·?
USART_InitStructure.USART_BaudRate = 115200;//?¨?????è??
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(UART4, &USART_InitStructure);
USART_ITConfig(UART4, USART_IT_RXNE, ENABLE);
USART_Cmd(UART4, ENABLE);
USART_ClearFlag(UART4, USART_FLAG_RXNE);
}
void Nvic_Init(void)
{
NVIC_InitTypeDef NVIC_InitStructure;[/mw_shl_code]
[mw_shl_code=c,true] /* ??????????????????·??? */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
/*1--?®?????????í*/
NVIC_InitStructure.NVIC_IRQChannel = UART4_IRQn;//52;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;[/mw_shl_code]
[mw_shl_code=c,true] NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}[/mw_shl_code]
|