traps.c
来自「本例程是描述了通过PIC33FXXX单片机的I2C接口实现对单片机外围EEPRO」· C语言 代码 · 共 104 行
C
104 行
/**********************************************************************
* ADDITIONAL NOTES:
* 1. This file contains trap service routines (handlers) for hardware
* exceptions generated by the dsPIC33F device.
* 2. All trap service routines in this file simply ensure that device
* continuously executes code within the trap service routine. Users
* may modify the basic framework provided here to suit to the needs
* of their application.
**********************************************************************/
#if defined(__dsPIC33F__)
#include "p33fxxxx.h"
#elif defined(__PIC24H__)
#include "p24hxxxx.h"
#endif
void __attribute__((__interrupt__)) _OscillatorFail(void);
void __attribute__((__interrupt__)) _AddressError(void);
void __attribute__((__interrupt__)) _StackError(void);
void __attribute__((__interrupt__)) _MathError(void);
void __attribute__((__interrupt__)) _DMACError(void);
void __attribute__((__interrupt__)) _AltOscillatorFail(void);
void __attribute__((__interrupt__)) _AltAddressError(void);
void __attribute__((__interrupt__)) _AltStackError(void);
void __attribute__((__interrupt__)) _AltMathError(void);
void __attribute__((__interrupt__)) _AltDMACError(void);
/*
Primary Exception Vector handlers:
These routines are used if INTCON2bits.ALTIVT = 0.
All trap service routines in this file simply ensure that device
continuously executes code within the trap service routine. Users
may modify the basic framework provided here to suit to the needs
of their application.
*/
void __attribute__((interrupt, no_auto_psv)) _OscillatorFail(void)
{
INTCON1bits.OSCFAIL = 0; //Clear the trap flag
while (1);
}
void __attribute__((interrupt, no_auto_psv)) _AddressError(void)
{
INTCON1bits.ADDRERR = 0; //Clear the trap flag
while (1);
}
void __attribute__((interrupt, no_auto_psv)) _StackError(void)
{
INTCON1bits.STKERR = 0; //Clear the trap flag
while (1);
}
void __attribute__((interrupt, no_auto_psv)) _MathError(void)
{
INTCON1bits.MATHERR = 0; //Clear the trap flag
while (1);
}
void __attribute__((interrupt, no_auto_psv)) _DMACError(void)
{
INTCON1bits.DMACERR = 0; //Clear the trap flag
while (1);
}
/*
Alternate Exception Vector handlers:
These routines are used if INTCON2bits.ALTIVT = 1.
All trap service routines in this file simply ensure that device
continuously executes code within the trap service routine. Users
may modify the basic framework provided here to suit to the needs
of their application.
*/
void __attribute__((interrupt, no_auto_psv)) _AltOscillatorFail(void)
{
INTCON1bits.OSCFAIL = 0;
while (1);
}
void __attribute__((interrupt, no_auto_psv)) _AltAddressError(void)
{
INTCON1bits.ADDRERR = 0;
while (1);
}
void __attribute__((interrupt, no_auto_psv)) _AltStackError(void)
{
INTCON1bits.STKERR = 0;
while (1);
}
void __attribute__((interrupt, no_auto_psv)) _AltMathError(void)
{
INTCON1bits.MATHERR = 0;
while (1);
}
void __attribute__((interrupt, no_auto_psv)) _AltDMACError(void)
{
INTCON1bits.DMACERR = 0; //Clear the trap flag
while (1);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?