Saludos, estoy realizando un programa para realizar el monitoreo de la temperatura de tres tanques mediante sensore LM35 usando un pic18f452, el programa compila bien pero al realizar la simulacion en proteus me da el mensaje "stack overflow is forcing device reset" pero solo estoy usando el 24% de RAM, he notado que esto sucede cuando ejecuto algunas rutinas IF dentro del main pero no logro ver la razon, a ver si alguien puede ayudar
unsigned dato1,dato2,dato3,ac;
float datof1,datof2,datof3;
char txt1[14],txt2[14],txt3[14];
// Lcd pinout settings
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;
// Pin direction
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit led1 at PORTD.B0;
sbit led2 at PORTD.B1;
sbit led3 at PORTD.B2;
sbit B_1 at PORTC.B0;
sbit B_2 at PORTC.B1;
sbit B_3 at PORTC.B2;
void main() {
inicio:
trisd = 0;
trisa = 0XFF;
trisc = 0XFF;
PORTC = 0;
PORTD = 0;
adcon0 = 0b00000001;
ADCON1 = 0;
Lcd_Cmd(_LCD_CURSOR_OFF);
delay_ms(200);
Lcd_Init();
ADC_Init();
Lcd_Out(1,1,"***PROGRAMA PARA***");
Lcd_Out(2,1,"*MONITOREO DE TEMP.*");
delay_ms(1500);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"B1 para temp. S1");
delay_ms(1000);
Lcd_Out(2,1,"B2 para temp. S2");
delay_ms(1000);
Lcd_Out(3,1,"B3 para temp. S3");
delay_ms(1000);
Lcd_Out(4,1,"B4 para informacion");
delay_ms(3000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(3,1,"Rango 2->150 grados");
Lcd_Out(4,1,"grados celcius(C)");
delay_ms(3000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"*MONITOREO DE TEMP.*");
do {
PORTC = 0;
dato1= ADC_Read(0); //S1
datof1 = (float)dato1*5/1024;
datof1 = datof1*100;
floattoStr(datof1,txt1);
dato2= ADC_Read(1); //S2
datof2 = (float)dato2*5/1024;
datof2 = dato2*100;
floattoStr(datof2,txt2);
dato3= ADC_Read(2);
datof3 = (float)dato3*5/1024;
datof3 = datof3*100;
floattoStr(datof3,txt3);
if( dato1 > dato2 && dato1 > dato3){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"*MONITOREO DE TEMP.*");
Lcd_Out(3,14,"S1");
Lcd_Out(4,1,txt1);
Lcd_Out(4,10,"(g)");
led1 = 1;
delay_ms(1000);
}
if( dato2 > dato1 && dato2 > dato3){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"*MONITOREO DE TEMP.*");
Lcd_Out(3,14,"S2");
Lcd_Out(4,1,txt2);
Lcd_Out(4,10,"(g)");
led2 = 1;
delay_ms(1000);
}
if( dato3 > dato1 && dato3 > dato2){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"*MONITOREO DE TEMP.*");
Lcd_Out(3,14,"S3");
Lcd_Out(4,1,txt3);
Lcd_Out(4,10,"(g)");
led2 = 1;
delay_ms(1000);
}
if(B_1 = 1){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(3,1,"S1:");
Lcd_Out(4,1,txt1);
delay_ms(2000);
PORTC = 0;
Lcd_Cmd(_LCD_CLEAR);
}
if(B_2 = 1){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(3,1,"S2:");
Lcd_Out(4,1,txt2);
delay_ms(2000);
PORTC = 0;
Lcd_Cmd(_LCD_CLEAR);
}
if(B_3 = 1){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(3,1,"S3");
Lcd_Out(4,1,txt3);
delay_ms(2000);
PORTC = 0;
Lcd_Cmd(_LCD_CLEAR);
}
}while(1);
}