PIC24_DOG
Alle Dateien Funktionen Variablen Typdefinitionen Makrodefinitionen
traps.c
gehe zur Dokumentation dieser Datei
1 /******************************************************************************/
2 /* Files to Include */
3 /******************************************************************************/
4 
5 /* Device header file */
6 #if defined(__XC16__)
7  #include <xc.h>
8 #elif defined(__C30__)
9  #if defined(__PIC24E__)
10  #include <p24Exxxx.h>
11  #elif defined (__PIC24F__)||defined (__PIC24FK__)
12  #include <p24Fxxxx.h>
13  #elif defined(__PIC24H__)
14  #include <p24Hxxxx.h>
15  #endif
16 #endif
17 
18 #include <stdint.h> /* Includes uint16_t definition */
19 #include <stdbool.h> /* Includes true/false definition */
20 
21 /******************************************************************************/
22 /* Trap Function Prototypes */
23 /******************************************************************************/
24 
25 /* <Other function prototypes for debugging trap code may be inserted here> */
26 
27 /* Use if INTCON2 ALTIVT=1 */
28 void __attribute__((interrupt,no_auto_psv)) _OscillatorFail(void);
29 void __attribute__((interrupt,no_auto_psv)) _AddressError(void);
30 void __attribute__((interrupt,no_auto_psv)) _StackError(void);
31 void __attribute__((interrupt,no_auto_psv)) _MathError(void);
32 
33 #if defined(__PIC24F__)||defined(__PIC24H__)
34 
35 /* Use if INTCON2 ALTIVT=0 */
36 void __attribute__((interrupt,no_auto_psv)) _AltOscillatorFail(void);
37 void __attribute__((interrupt,no_auto_psv)) _AltAddressError(void);
38 void __attribute__((interrupt,no_auto_psv)) _AltStackError(void);
39 void __attribute__((interrupt,no_auto_psv)) _AltMathError(void);
40 
41 #endif
42 
43 /* Default interrupt handler */
44 void __attribute__((interrupt,no_auto_psv)) _DefaultInterrupt(void);
45 
46 #if defined(__PIC24E__)
47 
48 /* These are additional traps in the 24E family. Refer to the PIC24E
49 migration guide. There are no Alternate Vectors in the 24E family. */
50 void __attribute__((interrupt,no_auto_psv)) _HardTrapError(void);
51 void __attribute__((interrupt,no_auto_psv)) _DMACError(void);
52 void __attribute__((interrupt,no_auto_psv)) _SoftTrapError(void);
53 
54 #endif
55 
56 /******************************************************************************/
57 /* Trap Handling */
58 /* */
59 /* These trap routines simply ensure that the device continuously loops */
60 /* within each routine. Users who actually experience one of these traps */
61 /* can add code to handle the error. Some basic examples for trap code, */
62 /* including assembly routines that process trap sources, are available at */
63 /* www.microchip.com/codeexamples */
64 /******************************************************************************/
65 
66 /* Primary (non-alternate) address error trap function declarations */
67 void __attribute__((interrupt,no_auto_psv)) _OscillatorFail(void)
68 {
69  INTCON1bits.OSCFAIL = 0; /* Clear the trap flag */
70  while(1);
71 }
72 
73 void __attribute__((interrupt,no_auto_psv)) _AddressError(void)
74 {
75  INTCON1bits.ADDRERR = 0; /* Clear the trap flag */
76  while (1);
77 }
78 void __attribute__((interrupt,no_auto_psv)) _StackError(void)
79 {
80  INTCON1bits.STKERR = 0; /* Clear the trap flag */
81  while (1);
82 }
83 
84 void __attribute__((interrupt,no_auto_psv)) _MathError(void)
85 {
86  INTCON1bits.MATHERR = 0; /* Clear the trap flag */
87  while (1);
88 }
89 
90 #if defined(__PIC24F__)||defined(__PIC24H__)
91 
92 /* Alternate address error trap function declarations */
93 void __attribute__((interrupt,no_auto_psv)) _AltOscillatorFail(void)
94 {
95  INTCON1bits.OSCFAIL = 0; /* Clear the trap flag */
96  while (1);
97 }
98 
99 void __attribute__((interrupt,no_auto_psv)) _AltAddressError(void)
100 {
101  INTCON1bits.ADDRERR = 0; /* Clear the trap flag */
102  while (1);
103 }
104 
105 void __attribute__((interrupt,no_auto_psv)) _AltStackError(void)
106 {
107  INTCON1bits.STKERR = 0; /* Clear the trap flag */
108  while (1);
109 }
110 
111 void __attribute__((interrupt,no_auto_psv)) _AltMathError(void)
112 {
113  INTCON1bits.MATHERR = 0; /* Clear the trap flag */
114  while (1);
115 }
116 
117 #endif
118 
119 /******************************************************************************/
120 /* Default Interrupt Handler */
121 /* */
122 /* This executes when an interrupt occurs for an interrupt source with an */
123 /* improperly defined or undefined interrupt handling routine. */
124 /******************************************************************************/
125 void __attribute__((interrupt,no_auto_psv)) _DefaultInterrupt(void)
126 {
127  while(1);
128 }
129 
130 #if defined(__PIC24E__)
131 
132 /* These traps are new to the PIC24E family. Refer to the device Interrupt
133 chapter of the FRM to understand trap priority. */
134 void __attribute__((interrupt,no_auto_psv)) _HardTrapError(void)
135 {
136  while(1);
137 }
138 void __attribute__((interrupt,no_auto_psv)) _DMACError(void)
139 {
140  while(1);
141 }
142 void __attribute__((interrupt,no_auto_psv)) _SoftTrapError(void)
143 {
144  while(1);
145 }
146 
147 #endif
void __attribute__((interrupt, no_auto_psv))
Definition: traps.c:28