I'm doing some tests with external interruptions, I have the following code:
The schematic doesn't have too much of complication, it's the microcontroller having 5 V to Vdd coneccted Vss to GND and RC0 wired to INT0 to simulate the interruption.
But despite getting the 5 V in INT0 no attention of the interruption is fired.
I've already tested in both PULL_UPS_ON and _OFF with no difference.
Any idea of what can be failing? Thanks.
Code:
#define USE_OR_MASKS
#include <p18f4620.h>
#include "portb.h"
//-------------------------------Configuration setting ----------------------------------------------
/**
* Oscillator is configured as INT067
* Fail safe monitor is enabled
* watch dog timer is disabled
* Extended instruction mode is disabled
* oscillator switch over is enabled
*/
//#if defined(__18F4685) //If the selected device if PIC18F4685, then apply below settings else user will have to set
#pragma config OSC=INTIO67, FCMEN=ON, WDT=OFF, IESO=ON, XINST=OFF, LVP=OFF
//#endif
#pragma interruptlow ISRBajaPrioridad
void ISRBajaPrioridad(void){
Nop();
}
#pragma code PrioridadBaja = 0x18
void VectorBajaPrioridad(void){
// Instruccion insertada en la dirección 0x18.-
_asm goto ISRBajaPrioridad _endasm
}
#pragma code // Cerramos sección.-
#pragma interruptlow ISRAltaPrioridad
void ISRAltaPrioridad(void){
Nop();
}
// Creamos una nueva sección de código a partir de la dirección 0x08.-
#pragma code PrioridadAlta = 0x08
void VectorAltaPrioridad(void){
// Instruccion insertada en la dirección 0x08.-
_asm goto ISRAltaPrioridad _endasm
}
#pragma code // Cerramos sección.-
unsigned char PORTResult[5]={0,0,0,0,0};
void main(void)
{
unsigned char config=0;
ADCON1 = 0xFF;
TRISC=0x00;
//**************** configure INT0 with pullups enabled, falling edge *********************************
config = PORTB_CHANGE_INT_ON | FALLING_EDGE_INT | PORTB_PULLUPS_ON | PORTB_INT_PRIO_HIGH;;
OpenRB0INT(config ); //configures INT0 & enables it
//*************** configure INT1 with pullups enabled, falling edge **********************************
config=0;
config = PORTB_CHANGE_INT_ON | FALLING_EDGE_INT | PORTB_PULLUPS_ON | PORTB_INT_PRIO_LOW;;
OpenRB1INT( config); //configures and enables INT1
//*************** configure INT2 with pullups enabled, falling edge **********************************
config=0;
config = PORTB_CHANGE_INT_ON | FALLING_EDGE_INT | PORTB_PULLUPS_ON | PORTB_INT_PRIO_HIGH;;;
OpenRB2INT( config); //configures and enables INT2
//************** configure Change Notification in PORTB with pullups enabled, falling edge **************
config=0;
config = PORTB_CHANGE_INT_ON | PORTB_PULLUPS_ON;
OpenPORTB(config); //configures and enables change notification in PORTB
//**************** Check for interrupts ***********************************************************
while(1)
{
PORTC=0x01;
PORTC=0x00;
if( INTCONbits.INT0IF == 1) //Check for INT0
{
PORTResult[0]=1; //Ser flag to indicate occurence of INT0
INTCONbits.INT0IF = 0; //Clear INT0
}
if(INTCON3bits.INT1IF == 1) //Check for INT1
{
PORTResult[1]=1; //Ser flag to indicate occurence of INT1
INTCON3bits.INT1IF = 0; //Clear INT1
}
if(INTCON3bits.INT2IF == 1) //Check for INT2
{
PORTResult[2]=1; //Ser flag to indicate occurence of INT2
INTCON3bits.INT2IF = 0; //Clear INT2
}
if(INTCONbits.RBIF == 1) //Check for Change Notification interrupt
{
PORTResult[4]=1; //Ser flag to indicate occurence of Change Notification interrupt
INTCONbits.RBIF = 0; //Clear Change Notification interrupt
}
}
CloseRB0INT(); //disable INT0
CloseRB1INT(); //disable INT1
CloseRB2INT(); //disable INT2
ClosePORTB(); //disable Change notification
}
The schematic doesn't have too much of complication, it's the microcontroller having 5 V to Vdd coneccted Vss to GND and RC0 wired to INT0 to simulate the interruption.
But despite getting the 5 V in INT0 no attention of the interruption is fired.
I've already tested in both PULL_UPS_ON and _OFF with no difference.
Any idea of what can be failing? Thanks.
Last edited: