myru28
Member level 1
I've a pair of problem with a test I'm doing of external interrupts on that PIC.
The code is the following:
1st problem) RB1 despite having been declared as low priority enters the high priority vector when it should enter the low priority one (this is done simulating the code by software (MPLAB SIM).
2nd problem) Neither RB0 or RB1 seem to fire the interrupt if applying an external voltage while running the code in the PIC itself (via Pickit2).
Thanks.
The code is the following:
Code:
#include <p18f4620.h>
#include <delays.h>
#include <portb.h>
#pragma config OSC=INTIO67
#define true 1
volatile char bandera=0;
char a=0;
void int_extISR(void);
void int_extISRBajo(void);
// Creamos una nueva seccion de codigo a partir de la direccion 0x08.-
#pragma code Interrupcion = 0X0008
void VectorInterrupcion(void){
_asm goto int_extISR _endasm
}
#pragma code // Cerramos seccion.-
// Rutina de Interrupcion.-
#pragma interrupt int_extISR
void int_extISR(void){
if(INTCONbits.INT0IF==1){
bandera=1; // Indicamos que se ha producido la interrupción.-
INTCONbits.INT0IF=0; // Borramos bandera.-
}
}
#pragma code Interrupcion2 = 0X0018
void VectorInterrupcionBajo(void){
_asm goto int_extISRBajo _endasm
}
#pragma code // Cerramos seccion.-
// Rutina de Interrupcion.-
#pragma interruptlow int_extISRBajo
void int_extISRBajo(void){
if(INTCON3bits.INT1IF==1){
bandera=1; // Indicamos que se ha producido la interrupción.-
INTCON3bits.INT1IF=0; // Borramos bandera.-
}
}
void main(void){
TRISC=0x00;
ADCON1=0x7f;
OSCCON=0b1110010; //Oscilador interno a 8MHz
TRISA=255; //puerto a entradas
TRISB=0x7f; //solo RB7 salida
LATBbits.LATB7=1; //RB7 puesto a uno
OpenPORTB(PORTB_CHANGE_INT_ON | PORTB_PULLUPS_OFF| PORTB_INT_PRIO_LOW);
OpenRB0INT(PORTB_CHANGE_INT_ON | FALLING_EDGE_INT | PORTB_PULLUPS_OFF | PORTB_INT_PRIO_HIGH);
OpenRB1INT(PORTB_CHANGE_INT_ON | FALLING_EDGE_INT | PORTB_PULLUPS_OFF | PORTB_INT_PRIO_LOW);
PORTC=0x01;
PORTC=0x00;
PORTC=0x01;
RCONbits.IPEN=1; // habilitamos Prioridades
INTCONbits.GIEH = 1; //enable interrupts
INTCONbits.GIEL = 1; //enable low interrupts
//INTCONbits.INTE = 1; //enable RB0/INT interrupts
while(true){
bandera=0;
}
}
}
1st problem) RB1 despite having been declared as low priority enters the high priority vector when it should enter the low priority one (this is done simulating the code by software (MPLAB SIM).
2nd problem) Neither RB0 or RB1 seem to fire the interrupt if applying an external voltage while running the code in the PIC itself (via Pickit2).
Thanks.