About the use of CAN interrupt in STM32

Publisher:dst2015Latest update time:2015-08-24 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
    "If you are using PA11 and PA12 CAN pins, use CAN1_RX0_IRQn for receive interrupts. If PB8 and PB9 are used as CAN pins, that is, redefined pins, use CAN1_RX1_IRQn for receive interrupts. Since PA11 and PA12 are also USB pins, the library file for non-interconnected microcontrollers with CAN controllers uses USB_LP_CAN1_RX0_IRQn when naming them." For specific definitions, please refer to the stm32F10x.h file, which has specific definitions for interrupts of different models.

 

Here is an example:

1. Configure filters

 CAN_FilterInitStructure.CAN_FilterNumber = 0;

 CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;

   CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;

 CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000;

 CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;

 CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;
 CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;

 CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_FIFO0;   //关联FIFO0

 CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;

 CAN_FilterInit(&CAN_FilterInitStructure);

  
 CAN_FilterInitStructure.CAN_FilterNumber = 14;

 CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_FIFO1;   //关联FIFO1

 CAN_FilterInit(&CAN_FilterInitStructure);

 

2. Enable CAN interrupt

     

   CAN_ITConfig(CAN1, CAN_IT_FMP0, ENABLE);

   CAN_ITConfig(CAN1, CAN_IT_FMP1, ENABLE);
 

   CAN_ITConfig(CAN2, CAN_IT_FMP0, ENABLE);

   CAN_ITConfig(CAN2, CAN_IT_FMP1, ENABLE);

 

3. Interrupt handling function


void CAN1_RX0_IRQHandler(void)

{
        CAN_Receive(CAN1, CAN_FIFO0, &CAN1_RxMsg);

 //
}


void CAN1_RX1_IRQHandler(void)

{
        CAN_Receive(CAN1, CAN_FIFO1, &CAN1_RxMsg);

        //
}

void CAN2_RX0_IRQHandler(void)

{

        CAN_Receive(CAN2, CAN_FIFO0, &CAN2_RxMsg);
       //
}


void CAN2_RX1_IRQHandler(void)

{
        CAN_Receive(CAN2, CAN_FIFO1, &CAN2_RxMsg);
        //
}

Keywords:STM32 Reference address:About the use of CAN interrupt in STM32

Previous article:The difference between the STM32 data sheet and the technical reference manual
Next article:Detailed description of the CMSIS file for the STM32 firmware library V3.5.0

Recommended ReadingLatest update time:2024-11-16 15:47

STM32 KEY control LED
The learning of stm32 is to understand how to configure the software, first understand the hardware connection, and then combine them; #include "stm32f4xx.h" #include "led.h" #define KEY0 GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_4) // Read the IO status here and use the IO port of stm32 as input #define KEY1 G
[Microcontroller]
STM32 usb_prop.c file analysis and some data definition analysis of usb_core.h
The usb_prop.c file is a very important file because many USB processing functions are defined here. Some processing in the USB establishment phase, data phase or status phase is in this file, and the USB standard function request function is also in this file. usb_prop.c starts with a series of structures, as follows
[Microcontroller]
stm32 timer input capture pwm
It took me two days to finally understand the timer input capture of stm32f103. Here I take the channel ch1 of TIM3 as an example. To realize input capture, you need to configure the registers, TIMx_ARR, TIMx_PSC, TIMx_CCMR1, TIMx_CCER, TIMx_DIER, TIMx_CR1, TIMx_CCR1. Here are some pictures of the register description
[Microcontroller]
STM32 learning - low power mode
Chip model: STM32F10X Reference: STM32F10XXX User Manual  Zhu Youpeng's MCU Complete Learning Course In the power management system of STM32, software engineers need to focus on the selection and implementation of low-power modes. When designing a product, there will be situations where lower power consumption is requ
[Microcontroller]
STM32 learning - low power mode
STM32 and Actility ThingPark collaborate to enable efficient wireless firmware updates
In the field of Internet of Things (IoT), the introduction of wireless firmware update (FUOTA) technology has significantly improved the efficiency and flexibility of device management. The combination of STM32 and Actility ThingPark platform provides developers with a powerful tool that enables them to set up and e
[Microcontroller]
Understanding of several STM32 GPIO registers
Using the BRR and BSRR registers, you can easily and quickly implement operations on certain specific bits of the port without affecting the status of other bits. For example, if you want to quickly flip bit 7 of GPIOE, you can: GPIOE- BSRR = 0x80; // set to '1' GPIOE- BRR = 0x80; // set to '0' If using the convention
[Microcontroller]
STM32 NVIC Learning
Read NVIC: System Interrupt Management.  My understanding is that it manages the interrupts within the system and is responsible for turning on and off interrupts.  Basic Application 1, the initialization function of the interrupt, including setting the interrupt vector table location and turning on the required inter
[Microcontroller]
STM32 USB keyboard and mouse routines
STM32 USB keyboard and mouse routines can be found on the Internet, but routines that integrate keyboard and mouse in the same device are relatively rare (I only found the 51+D12 version of Quanquan through GOOGLE). The following is a program for STM32 with integrated keyboard and mouse that I made with reference to
[Industrial Control]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号