Thanks to JPC for his wonderful help in another thread regarding On Change events.
I however need to get a sample of how to setup and use the External Interrupt.
I have to be able to get a trigger on a rising edge only (or falling only) to a set pin.
I am getting desperate and confused now and have read all of the manuals I can find.
I am using the LV32MX board with the PIC32MX360F128L.
Here s what I have tried so far.
Code: Select all
program RFIDTest;
// LCD module connections
var LCD_RS : sbit at LATB2_bit;
var LCD_EN : sbit at LATB3_bit;
var LCD_D4 : sbit at LATB4_bit;
var LCD_D5 : sbit at LATB5_bit;
var LCD_D6 : sbit at LATB6_bit;
var LCD_D7 : sbit at LATB7_bit;
var LCD_RS_Direction : sbit at TRISB2_bit;
var LCD_EN_Direction : sbit at TRISB3_bit;
var LCD_D4_Direction : sbit at TRISB4_bit;
var LCD_D5_Direction : sbit at TRISB5_bit;
var LCD_D6_Direction : sbit at TRISB6_bit;
var LCD_D7_Direction : sbit at TRISB7_bit;
// End LCD module connections
var z:word;
tempDummy : word;
procedure External3Interrupt(); iv IVT_EXTERNAL_3; ilevel 2; ics ICS_AUTO;
var dummy: word;
begin
dummy := portA;
latc1_bit := 1;
IFS0.INT1IF :=0;
end;
procedure init_all;
begin
//Initialize_RFIDSection;
tempDummy := 0;
DisableInterrupts();
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
LCD_Out(1, 1, 'Robert Spencer '); // Write text in first row
LCD_Out(2, 1, 'RFID Reader '); // Write text in second row
delay_ms(100);
TRISC.1 := 0;
TRISC.2 := 0;
TRISC.3 := 0;
AD1PCFG := 0xFFFF; //Configure for digital
TRISC.1 := 0;
TRISA.14 := 1; //External Interupt 3
IPC0Set := 0x00000008; // set priority level to 2
IEC0.INT3IE :=1;
EnableInterrupts();
end;
begin
init_all;
while true do
begin
LATC.1 := 0;
LATC.2 := 0;
latc.3 := not portc.3;
delay_ms(1000);
end;
end.