LIN总线中断

2019-07-21 07:32发布

各位大神,有没有搞过lin总线的我配置的为什么不能进中断,void USART2_IRQHandler(void)
{
                        LED0=1;               
            lin_data.ID=USART_ReceiveData(USART2);
}
                                                                 

void RS485_Init(void)
{  
  GPIO_InitTypeDef  GPIO_InitStructure;
  USART_InitTypeDef USART_InitStructure;
        NVIC_InitTypeDef  NVIC_InitStructure;

        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);//ê1ÄüGPIOA,Dê±Öó
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);//ê1ÄüUSART2ê±Öó
       
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;        //PA2
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;        //¸′óÃíÆíì
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;//PA3
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //¸¡¿Õêäèë
  GPIO_Init(GPIOA, &GPIO_InitStructure);  


        USART_InitStructure.USART_BaudRate = 19200;//2¨ìØÂêéèÖÃ
        USART_InitStructure.USART_WordLength = USART_WordLength_8b;//8λêy¾Y3¤¶è
        USART_InitStructure.USART_StopBits = USART_StopBits_1;//ò»¸öí£Ö1λ
        USART_InitStructure.USART_Parity = USART_Parity_No;///ÆæżD£Ñéλ
        USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//ÎTó2¼têy¾Yá÷¿ØÖÆ
        USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;//êÕ·¢Ä£ê½
  USART_Init(USART2, &USART_InitStructure); ; //3õê¼»ˉ′®¿ú

        USART_LINBreakDetectLengthConfig(USART2, USART_LINBreakDetectLength_11b);
  USART_LINCmd(USART2, ENABLE);
  USART_Cmd(USART2, ENABLE);   //ê1Äü′®¿ú
       
       
        USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
  USART_ITConfig(USART2, USART_IT_TXE, DISABLE);
  USART_ITConfig(USART2, USART_IT_LBD, DISABLE);

        NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; //ê1Äü′®¿ú2ÖD¶Ï
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; //ÏèÕ¼óÅÏ輶2¼¶
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; //′óóÅÏ輶2¼¶
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //ê1Äüía2¿ÖD¶Ïí¨μà
        NVIC_Init(&NVIC_InitStructure); //¸ù¾YNVIC_InitStructÖDÖ¸¶¨μÄ2Îêy3õê¼»ˉíaéèNVIC¼Ä′æÆ÷
}

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。