-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExternal Interrupt.c
More file actions
44 lines (37 loc) · 1.34 KB
/
External Interrupt.c
File metadata and controls
44 lines (37 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* File: External Interrupt.c
* Author: asath
*
* Created on 24 October, 2025, 5:32 PM
*/
#include <xc.h>
#define _XTAL_FREQ 20000000
// CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = ON // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3/PGM pin has PGM function; low-voltage programming enabled)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
void interrupt external()
{
if(INTCONbits.INTF == 1)
{
PORTCbits.RC0 = ~PORTCbits.RC0;
INTCONbits.INTF = 0;
}
}
void main(void)
{
INTCONbits.GIE = 1;
INTCONbits.PEIE = 1;
INTCONbits.INTE = 1;
OPTION_REGbits.INTEDG = 1;
TRISC0 = 0;
while(1)
{
}
return;
}