Podrias pasar de nuevo el codigo?.
Mas que eso es como si se llamara continuamente a una funcion y nunca se volviera, interrupcion dentro de otra interrupcion, muchas veces seguidas, lo cual es absurdo ya que al entrar se deshabilitan las mismas.
Y es C, con lo cual el tema de CALL - RETURN se manejan solos. Te piedo el codigo para probarlo yo en mi PC y ver cual es el problema.
// PIC18F4550 Configuration Bit Settings
// 'C' source line config statements
#include <xc.h>
#include "LCD_4bits.h"
#include <stdio.h>
#include "adc_4550.h"
// #pragma config statements should precede project file includes.
// Use project enums instead of#define for ON and OFF.
// CONFIG1L
#pragma config PLLDIV = 1 // PLL Prescaler Selection bits (No prescale (4 MHz oscillator input drives PLL directly))
#pragma config CPUDIV = OSC1_PLL2// System Clock Postscaler Selection bits ([Primary Oscillator Src: /1][96 MHz PLL Src: /2])
#pragma config USBDIV = 1 // USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes directly from the primary oscillator block with no postscale)
// CONFIG1H
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator (HS))
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)
// CONFIG2L
#pragma config PWRT = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOR = ON // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
#pragma config BORV = 3 // Brown-out Reset Voltage bits (Minimum setting)
#pragma config VREGEN = OFF // USB Voltage Regulator Enable bit (USB voltage regulator disabled)
// CONFIG2H
#pragma config WDT = ON // Watchdog Timer Enable bit (WDT enabled)
#pragma config WDTPS = 32768 // Watchdog Timer Postscale Select bits (1:32768)
// CONFIG3H
#pragma config CCP2MX = ON // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
#pragma config PBADEN = OFF // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
#pragma config LPT1OSC = OFF // Low-Power Timer 1 Oscillator Enable bit (Timer1 configured for higher power operation)
#pragma config MCLRE = ON // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)
// CONFIG4L
#pragma config STVREN = ON // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = ON // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
#pragma config ICPRT = OFF // Dedicated In-Circuit Debug/Programming Port (ICPORT) Enable bit (ICPORT disabled)
#pragma config XINST = OFF // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))
// CONFIG5L
#pragma config CP0 = OFF // Code Protection bit (Block 0 (000800-001FFFh) is not code-protected)
#pragma config CP1 = OFF // Code Protection bit (Block 1 (002000-003FFFh) is not code-protected)
#pragma config CP2 = OFF // Code Protection bit (Block 2 (004000-005FFFh) is not code-protected)
#pragma config CP3 = OFF // Code Protection bit (Block 3 (006000-007FFFh) is not code-protected)
// CONFIG5H
#pragma config CPB = OFF // Boot Block Code Protection bit (Boot block (000000-0007FFh) is not code-protected)
#pragma config CPD = OFF // Data EEPROM Code Protection bit (Data EEPROM is not code-protected)
// CONFIG6L
#pragma config WRT0 = OFF // Write Protection bit (Block 0 (000800-001FFFh) is not write-protected)
#pragma config WRT1 = OFF // Write Protection bit (Block 1 (002000-003FFFh) is not write-protected)
#pragma config WRT2 = OFF // Write Protection bit (Block 2 (004000-005FFFh) is not write-protected)
#pragma config WRT3 = OFF // Write Protection bit (Block 3 (006000-007FFFh) is not write-protected)
// CONFIG6H
#pragma config WRTC = OFF // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
#pragma config WRTB = OFF // Boot Block Write Protection bit (Boot block (000000-0007FFh) is not write-protected)
#pragma config WRTD = OFF // Data EEPROM Write Protection bit (Data EEPROM is not write-protected)
// CONFIG7L
#pragma config EBTR0 = OFF // Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF // Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR2 = OFF // Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR3 = OFF // Table Read Protection bit (Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks)
// CONFIG7H
#pragma config EBTRB = OFF // Boot Block Table Read Protection bit (Boot block (000000-0007FFh) is not protected from table reads executed in other blocks)
void main (void)
{
float presion1, presion2, presion3, presion4, presion5;
float presion1_anterior = 0, presion2_anterior = 0, presion3_anterior = 0, presion4_anterior = 0, presion5_anterior = 0; // para que solo escriba en pantalla si cambia la presion
char T[17]; // cadena de 16 caracteres incluyendo el final \0
//TRISCbits.RC0=0;
//TRISC=0X00;
TRISB=0x1F; // RB2 entrada pulsado para silenciar alarma
TRISA=0x6F; // RA4 SALIDA DE ALARMA
//TRISE=0x0F; //entrada analogica #6 en RE1
LCD_init();
ADC_init(0x09 | ADC_10bit | ADC_FOSC32 | ADC_02TAD ); // 6 entradas analogicas
//ADC_init(ADC_AN01 | ADC_10bit | ADC_FOSC32 | ADC_02TAD );
//ADC_init(ADC_AN02 | ADC_10bit | ADC_FOSC32 | ADC_02TAD );
//ADC_init(ADC_AN03 | ADC_10bit | ADC_FOSC32 | ADC_02TAD );
//ADC_init(ADC_AN04 | ADC_10bit | ADC_FOSC32 | ADC_02TAD );
// ADC_init(ADC_AN05 | ADC_10bit | ADC_FOSC32 | ADC_02TAD );
/*CONFIGURACION INTERRUPCION EN RB2*/
RCONbits.IPEN = 1; // Activa modo alta y baja prioridad
INTCONbits.GIEL = 1;// permitimos interrupciones de baja prioridad (Global Interrupt Enable Low)
INTCONbits.GIEH=1; //alto en ultima compuerta
INTCON2bits.INTEDG2 = 1;//configura interrupcion por flanco de subida para la interrupcion en RB2
INTCON3bits.INT2IE=1; // activa la interrupción externa por flanco del pin RB2
INTCON3bits.INT2IP=0; // selecciona la interrupción de baja prioridad del pin RB2
/*CONFIGURACION INTERRUPCION EN RB2*/
LCD_clear();
while (1)
{
//presion = (float)ADC_get(0); calculo de numero binario para voltaje analogico (se utilizo para hallar el numero binario para cada voltaje analogico
presion1=(((float)ADC_get(0)/203.7221)-0.5)/0.01333333333;
if (presion1<30)
{
if(presion1 != presion1_anterior)
{
sprintf(T, "%03.1f %c ", presion1, 0x3C);
LCD_gotoxy(0,0);
LCD_puts(T);
presion1 = presion1_anterior;
LATBbits.LATB5=1;
LATAbits.LATA4=1;
}
}
else if (presion1 >= 30 && presion1 <=40)
{
if(presion1 != presion1_anterior)
{
sprintf(T, "%03.1f %c", presion1, 0x2D);
LCD_gotoxy(0,0);
LCD_puts(T);
presion1 = presion1_anterior;
LATBbits.LATB6=1;
LATBbits.LATB5=0;
LATBbits.LATB7=0;
}
}
else
{
if(presion1 != presion1_anterior)
{
sprintf(T, "%03.1f %c", presion1, 0x3E);
LCD_gotoxy(0,0);
LCD_puts(T);
presion1 = presion1_anterior;
LATBbits.LATB7=1;
}
}
presion2=(((float)ADC_get(1)/203.7221)-0.5)/0.01333333333;
if (presion2<30)
{
if(presion2 != presion2_anterior)
{
sprintf(T, "%03.1f %c ", presion2, 0x3C);
LCD_gotoxy(0,1);
LCD_puts(T);
presion2 = presion2_anterior;
LATBbits.LATB5=1;
}
}
else if (presion2 >= 30 && presion2 <=40)
{
if(presion2 != presion2_anterior)
{
sprintf(T, "%03.1f %c", presion2, 0x2D);
LCD_gotoxy(0,1);
LCD_puts(T);
presion2 = presion2_anterior;
LATBbits.LATB6=1;
LATBbits.LATB5=0;
LATBbits.LATB7=0;
}
}
else
{
if(presion2 != presion2_anterior)
{
sprintf(T, "%03.1f %c", presion2, 0x3E);
LCD_gotoxy(0,1);
LCD_puts(T);
presion2 = presion2_anterior;
LATBbits.LATB7=1;
}
}
presion3=(((float)ADC_get(2)/203.7221)-0.5)/0.01333333333;
if (presion3<30)
{
if(presion3 != presion3_anterior)
{
sprintf(T, "%03.1f %c ", presion3, 0x3C);
LCD_gotoxy(0,2);
LCD_puts(T);
presion3 = presion3_anterior;
LATBbits.LATB5=1;
}
}
else if (presion3 >= 30 && presion3 <=40)
{
if(presion3 != presion3_anterior)
{
sprintf(T, "%03.1f %c", presion3, 0x2D);
LCD_gotoxy(0,2);
LCD_puts(T);
presion3 = presion3_anterior;
LATBbits.LATB6=1;
LATBbits.LATB5=0;
LATBbits.LATB7=0;
}
}
else
{
if(presion3 != presion3_anterior)
{
sprintf(T, "%03.1f %c", presion3, 0x3E);
LCD_gotoxy(0,2);
LCD_puts(T);
presion3 = presion3_anterior;
LATBbits.LATB7=1;
}
}
presion4=(((float)ADC_get(3)/203.7221)-0.5)/0.01333333333;
if (presion4<30)
{
if(presion4 != presion4_anterior)
{
sprintf(T, "%03.1f %c ", presion4, 0x3C);
LCD_gotoxy(0,3);
LCD_puts(T);
presion4 = presion4_anterior;
LATBbits.LATB5=1;
}
}
else if (presion4 >= 30 && presion4 <=40)
{
if(presion4 != presion4_anterior)
{
sprintf(T, "%03.1f %c", presion4, 0x2D);
LCD_gotoxy(0,3);
LCD_puts(T);
presion4 = presion4_anterior;
LATBbits.LATB6=1;
LATBbits.LATB5=0;
LATBbits.LATB7=0;
}
}
else
{
if(presion4 != presion4_anterior)
{
sprintf(T, "%03.1f %c", presion4, 0x3E);
LCD_gotoxy(0,3);
LCD_puts(T);
presion4 = presion4_anterior;
LATBbits.LATB7=1;
}
}
presion5=(((float)ADC_get(4)/203.7221)-0.5)/0.01333333333;
if (presion5<30)
{
if(presion5 != presion5_anterior)
{
sprintf(T, "%03.1f %c ", presion5, 0x3C);
LCD_gotoxy(9,0);
LCD_puts(T);
presion5 = presion5_anterior;
LATBbits.LATB5=1;
}
}
else if (presion5 >= 30 && presion5 <=40)
{
if(presion5 != presion5_anterior)
{
sprintf(T, "%03.1f %c", presion5, 0x2D);
LCD_gotoxy(9,0);
LCD_puts(T);
presion5 = presion5_anterior;
LATBbits.LATB6=1;
LATBbits.LATB5=0;
LATBbits.LATB7=0;
}
}
else
{
if(presion5 != presion5_anterior)
{
sprintf(T, "%03.1f %c", presion5, 0x3E);
LCD_gotoxy(9,0);
LCD_puts(T);
presion5 = presion5_anterior;
LATBbits.LATB7=1;
}
}
/*LCD_gotoxy(0,0);
LCD_puts("linea 1");
LCD_gotoxy(0,1);
LCD_puts("linea 2");
LCD_gotoxy(0,2);
LCD_puts("linea 3");
LCD_gotoxy(0,3);
LCD_puts("linea 4");*/
}
}
//volatile int myVolatileVariable=0;//variable para utilizar con las interrupciones
void interrupt isr (void)//prototipo de la interrupción de baja prioridad
{
if(INTCON3bits.INT2IF==1) //pregunta por bandera de interrupción
{
LATAbits.LATA4= 0; // invierto estado del led
//myVolatileVariable++;
INTCON3bits.INT2IF = 0; //limpia bandera y salimos
}
//return;
}