发送内容是正常的,但是pc发送给单片机进入不了中断,单片机引脚焊接正常,用示波器量也有波形产生
void USART_GPIOConfiguation(void)
{
GPIO_InitPara GPIO_InitStructure;
/* 开启IO时钟和复用时钟 */
RCC_APB2PeriphClock_Enable( RCC_APB2PERIPH_GPIOC , ENABLE );
RCC_APB2PeriphClock_Enable( RCC_APB2PERIPH_AF, ENABLE );
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_10 ;
GPIO_InitStructure.GPIO_Mode = GPIO_MODE_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_50MHZ;
GPIO_Init( GPIOC , &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_11;
GPIO_InitStructure.GPIO_Mode = GPIO_MODE_IN_FLOATING;;
GPIO_Init( GPIOC , &GPIO_InitStructure);
GPIO_PinRemapConfig(GPIO_PARTIAL_REMAP_USART3, ENABLE);
void USART_InitConfiguation(u32 bound)
{
USART_InitPara USART_InitStructure;
USART_DeInit( USART3 );
USART_InitStructure.USART_BRR = bound;
USART_InitStructure.USART_WL = USART_WL_8B;
USART_InitStructure.USART_STBits = USART_STBITS_1;
USART_InitStructure.USART_Parity = USART_PARITY_RESET;
USART_InitStructure.USART_HardwareFlowControl = USART_HARDWAREFLOWCONTROL_NONE;
USART_InitStructure.USART_RxorTx = USART_RXORTX_RX | USART_RXORTX_TX;
USART_Init(USART3, &USART_InitStructure);
/* USART enable */
USART_Enable(USART3, ENABLE);
}
void NVIC_Configuration(void)
{
NVIC_InitPara NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQ = USART3_IRQn; // 串口3中断通道
NVIC_InitStructure.NVIC_IRQPreemptPriority = 0;
NVIC_InitStructure.NVIC_IRQSubPriority = 0;
NVIC_InitStructure.NVIC_IRQEnable = ENABLE; // IRQ通道使能
NVIC_Init(&NVIC_InitStructure); // 根据指定的参数初始化NVIC寄存器
USART_INT_Set(USART3, USART_INT_RBNE, ENABLE); // 开启相关中断
}
void USART3_IRQHandler(void)
{
if(USART_GetIntBitState( USART3, USART_FLAG_RBNE) != RESET)
{
USART_ClearBitState(USART3,USART_FLAG_RBNE);
printf("%c",USART_DataReceive(USART3));
}
us_flag = 1;
}
|