You are on page 1of 3

13/10/2010 7:53:02 µµ

1: ' RB0/INT External Interrupt


2: '***************************
3:
4: ' Interrupt Handler
5: void interrupt()
6: {
7: ' RB0/INT External Interrupt
8: if(INTCON.INTF == 1) ' if the RB0/INT External Interrupt flag is set...
9: {
10: INTCON.INTF =0;
11: }
12: }
13: ' code starts here...
14: void main()
15: {
16: ' Set Interrupt Enable bits
17: INTCON.INTE = 1; ' bit 4 RB0/INT External Interrupt Enable
18:
19: 'Set global Interrupt Enable bits
20: INTCON.GIE = 1; ' global interrput enable
21:
22: while(1) 'endless loop
23: {
24: }
25: }
26:
27: ' RB Port Change Interrupt
28: '***************************
29:
30: ' Interrupt Handler
31: void interrupt()
32: {
33: ' RB Port Change Interrupt
34: if(PIR1.RBIF == 1) ' if the RB Port Change Interrupt flag is set...
35: {
36: x = PORTB; ' Need to read or write to the port to clear mismatch
condition
37: PIR1.RBIF =0;
38: }
39: }
40: ' code starts here...
41: void main()
42: {
43: ' Set Interrupt Enable bits
44: INTCON.RBIE = 1; ' bit 3 RB Port Change Interrupt Enable
45:
46: 'Set global Interrupt Enable bits
47: INTCON.GIE = 1; ' global interrput enable
48:
49: while(1) 'endless loop
50: {
51: }
52: }
53:
54:
55:
56:
57:
58:
59:
60:

1/3 mikroBasic compiler for PIC by mikroElektronika


13/10/2010 7:53:02 µµ

61:
62: 'PSPIF: Parallel Slave Port Read/Write Interrupt
63: '**************************************************
64:
65: ' Interrupt Handler
66: void interrupt()
67: {
68: ' Parallel Slave Port Read/Write Interrupt
69: if(PIR1.PSPIF == 1) ' if the ADC complete interrupt flag is set...
70: {
71: PIR1.PSPIF =0;
72: }
73: }
74: ' code starts here...
75: void main()
76: {
77: ' Set Interrupt Enable bits
78: PIE1.PSPIE = 1; ' bit 7 Parallel Slave port Read/Write Interrupt Enable
79:
80: 'Set global Interrupt Enable bits
81: INTCON.GIE = 1; ' global interrput enable
82:
83: while(1) 'endless loop
84: {
85: }
86: }
87:
88: 'CCP1IF: CCP1 Interrupt
89: '**********************
90:
91: ' Interrupt Handler
92: void interrupt()
93: {
94: ' CCP1 Interrupt
95: if(PIR1.CCP1IF == 1) ' if the CCP1 Interrupt flag is set...
96: {
97: PIR1.CCP1IF =0;
98: }
99: }
100: ' code starts here...
101: void main()
102: {
103: ' Set Interrupt Enable bits
104: PIE1.CCP1IE = 1; ' bit 2 CCP1 Interrupt Enable
105:
106: 'Set global Interrupt Enable bits
107: INTCON.GIE = 1; ' global interrput enable
108:
109: while(1) 'endless loop
110: {
111: }
112: }
113:
114:
115:
116:
117:
118:
119:
120:
121:

2/3 mikroBasic compiler for PIC by mikroElektronika


13/10/2010 7:53:02 µµ

122:
123:
124: 'CMIF: Comparator Interrupt
125: '***************************
126:
127: ' Interrupt Handler
128: void interrupt()
129: {
130: 'Comparator Interrupt Handler
131: if (PIR2.CMIF == 1) ' Comparator Interrupt
132: {
133: PIR2.CMIF = 0; ' interrupt must be cleared by software
134: }
135: }
136: ' code starts here...
137: void main()
138: {
139: ' Set Interrupt Enable bits
140: PIE2.CMIE = 1; ' bit 6 Comparitor Interrpt Enable
141:
142: 'Set global Interrupt Enable bits
143: INTCON.GIE = 1; ' global interrput enable
144: INTCON.PEIE = 1; ' Peripheral Interrupt Enable bit...1 = Enables all
unmasked peripheral interrupts
145:
146: while(1) 'endless loop
147: {
148: }
149: }
150:
151: 'CCP2IF: CCP2 Interrupt
152: '**********************
153:
154: ' Interrupt Handler
155: void interrupt()
156: {
157: 'CCP2 Interrupt Handler
158: if (PIR2.CCP2IF == 1) ' CCP2 Interrupt
159: {
160: PIR2.CCP2IF: = 0; ' interrupt must be cleared by software
161: }
162: }
163: ' code starts here...
164: void main()
165: {
166: ' Set Interrupt Enable bits
167: PIE2.CCP2IE = 1; ' bit 0 CCP2 Interrupt Enable
168:
169: 'Set global Interrupt Enable bits
170: INTCON.GIE = 1; ' global interrput enable
171: INTCON.PEIE = 1; ' Peripheral Interrupt Enable bit...1 = Enables all
unmasked peripheral interrupts
172:
173: while(1) 'endless loop
174: {
175: }
176: }
177:

3/3 mikroBasic compiler for PIC by mikroElektronika

You might also like