CAN error interrupt 1 in STM32

Publisher:码梦狂人Latest update time:2015-11-19 Source: eefocusKeywords:STM32  CAN Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
void can_signal(void)
{
unsigned char data can_irq;
unsigned char data temp;
x_wdgtime();
can_irq = InterruptReg;
if(can_irq&ALI_Bit)
{ // Arbitration lost bit
++al_counter;
temp=ArbLostCapReg; // Read arbitration lost register
alc_current=temp&0x1F; // Get the current arbitration lost position
}
if(can_irq & BEI_Bit)
{ // Bus error interrupt
temp=ErrCodeCapReg;
buse_current=temp&0x3F;
temp=temp&0xD0; //Get the type of bus error
switch (temp) 
{
case 0x00: ++bite_counter;
case 0x40: ++forme_counter;
case 0x80: ++stuffe_counter;
case 0xd0: ++othere_counter;
}
}
if(can_irq & EPI_Bit)
{ // Negative error interrupt,
// When the receive or send error count exceeds 127, the error state becomes a passive error
if((RxErrCountReg>127)||(TxErrCountReg>127)) errstatus_current=ERR_PASSIVE;
// When the receive or send error count returns to less than 127, the error status becomes active error
if((RxErrCountReg<127)&&(TxErrCountReg<127)) errstatus_current=ERR_ACTIVE;
}
if(can_irq & DOI_Bit)
{ // data overflow
CommandReg = (CDO_Bit|RRB_Bit);
return;
}
if(can_irq&EI_Bit)
{ // Error alarm interrupt, only bus close error is processed here
if(StatusReg&BS_Bit)
{ // Check the bus status bit of the status register
++busoff_counter;
ModeControlReg = 0x00;
return;
}
}
if(can_irq & RI_Bit)
{ // Receive data interrupt
if(StatusReg & DOS_Bit)
{
CommandReg = (CDO_Bit|RRB_Bit);
return;
}
can_readmsg();
return;
}
 
return;
}

Keywords:STM32  CAN Reference address:CAN error interrupt 1 in STM32

Previous article:CAN interrupt 2 in STM32
Next article:STM32 CAN---Error Management Analysis

Recommended ReadingLatest update time:2024-11-16 16:55

Designing precise delay function using STM32's SysTick
When using I2C interface sensors in a project, a more precise delay is required. After searching online, it is possible to do this without using the SysTick timer interrupt. The following information is found: It is mainly modeled after the "Incomplete Manual of STM32" of Atom. The clock of SYSTICK is fixed to 1/8 o
[Microcontroller]
Consequences of not restoring the clock when waking up from STM32 stop mode
For a detailed analysis of STM32's low power consumption, please refer to the interpretation of STM32's low power consumption mode . It is mentioned that when STM32 is in stop mode, the chip's 1.8V area clock is turned off, and the HSI and HSE clocks are also turned off. When an enabled interrupt or event occurs, STM3
[Microcontroller]
LPC1700 CAN communication routine
The microcontroller source program is as follows: /****************************************Copyright (c)**************************************************** ** **--------------File Info--------------------------------------------------------------------------------- ** File name:           main.c ** Last modified Da
[Microcontroller]
Pull-up and pull-down resistors for STM32
STM32F10X I/O can enable weak pull-up or pull-down resistors through the configuration register. According to the datasheet, this resistor is: min=20K, typ=30K, max=40K. The input of STM32F10X I/O can be configured as floating/pull up/pull down. For STM32F10X, the state of I/O after system reset is Floating input. S
[Microcontroller]
STM32, system clock setting and chip model library function selection
Model selection: In stm32f10x.h, it involves chip model selection, as shown in the figure: which chip is used, just remove the comment of the chip. For specific chip selection, refer to the comments below the program The frequency setting of the external high-speed clock is also in stm32f10x.h: The subsequent
[Microcontroller]
STM32, system clock setting and chip model library function selection
Summary of STM32 NVIC and interrupts
Preface:  1. To learn STM32 interrupts, you must first understand STM32's definition of priority;  2. Experience in 51 MCU development will make it easier to understand interrupt priorities;  3. This blog post is based on the STM32F103ZET6 chip and 3.5.0 standard library;  4. This blog post starts with registers and e
[Microcontroller]
Summary of STM32 NVIC and interrupts
stm32: firmware library file description
About the firmware library file description File description under the firmware library folder STM32F10x_StdPeriph_Lib_V3.5.0: 1. The main files in the Libraries folder are: 1. core_cm3.c , core_cm3.h : CMSIS core files, through the interface to enter the Cortex_M3 core 2. The startup folder contains the system
[Microcontroller]
Design of high-precision digital pressure transmitter based on CAN bus
0Introduction Pressure sensor is the most commonly used sensor in industrial field, which is widely used in various industrial control environments such as water conservancy and hydropower, railway transportation, intelligent building, production automatic control aerospace, military industry, petrochemical
[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号