TODOPIC

Microcontroladores PIC => Lenguaje C para microcontroladores PIC => Mensaje iniciado por: LucasBols en 10 de Abril de 2014, 16:01:52

Título: XC8 - possible hardware stack overflow detected, estimated stack depth: 14
Publicado por: LucasBols en 10 de Abril de 2014, 16:01:52
hola, buenas tardes,

estoy compilando con el XC8, y en el main me marca este posible desbordamiento, sin embargo esa línea, la 1939 es el inicio del main,

Código: [Seleccionar]
main.c:1083: warning: (1393) possible hardware stack overflow detected, estimated stack depth: 14

el main es este:

Código: C#
  1. void main(void)
  2. {
  3. //##############################################################################
  4. //##############################################################################
  5. //##############################################################################
  6.  
  7.     /*****************************
  8.      ******** T I M E R 1 ********
  9.      *****************************/
  10.     T1CONbits.TMR1CS  = 0; // Timer1 Clock Source - 0 Internal clock (FOSC/4) //******** esta es la 1939 ********
  11.  
  12.     T1CONbits.T1CKPS1 = 1; // prescaler
  13.     T1CONbits.T1CKPS0 = 1; // 1:8
  14.  
  15.     TMR1H = VALOR_TMR1H; // 3036
  16.     TMR1L = VALOR_TMR1L; // 500 ms
  17.  
  18.     T1CONbits.TMR1ON  = 0; // Timer1 On bit
  19.  
  20.     PIE1bits.TMR1IE   = 1; // TMR1 Overflow Interrupt Enable bit
  21.  
  22.     /*********************
  23.      *** P U E R T O S ***
  24.      *********************/
  25.     /**** PORTD I/O ****/
  26.     TRISEbits.PSPMODE = 0; // PORTD functions in general purpose I/O mode
  27.  
  28.     /**** PORTE I/O ****/
  29.     TRISEbits.TRISE2  = 0; // Output
  30.     TRISEbits.TRISE1  = 0; // Output
  31.     TRISEbits.TRISE0  = 0; // Output
  32.  
  33.     /**** PORTA / PORTE I/O ****/
  34.     ADCON1bits.PCFG3  = 0; // RA5:RA0 y RE2:RE0 Digital
  35.     ADCON1bits.PCFG2  = 1; // RA5:RA0 y RE2:RE0 Digital
  36.     ADCON1bits.PCFG1  = 1; // RA5:RA0 y RE2:RE0 Digital
  37.     ADCON1bits.PCFG0  = 1; // RA5:RA0 y RE2:RE0 Digital
  38.  
  39.     TRISA = 0b00000000; // Salida
  40.     TRISC = 0b00000000; // Salida
  41.     TRISD = 0b00000000; // Salida
  42.     TRISE = 0b00000000; // Salida
  43.  
  44.     PORTA = 0b00000000;
  45.     PORTB = 0b00000000;
  46.     PORTC = 0b00000000;
  47.     PORTD = 0b00000000; // puerto LCD
  48.     PORTE = 0b00000000;
  49. //##############################################################################
  50. //##############################################################################
  51. //##############################################################################
  52.  
  53. //    configurar_pic(); // lo de arriba estaba en esta funcion
  54.  
  55.     CD4094_LCD_inicializar();
  56.  
  57. //##############################################################################
  58. //##############################################################################
  59. //##############################################################################
  60.  
  61.     LCD_ENCENDER = 1;
  62.  
  63.     // inicializa la estructura
  64.     for ( char cnt = 0; cnt < 10; cnt++ )
  65.     {
  66.         du[cnt].iniciar         = 0;
  67.         du[cnt].seleccionada    = 0;
  68.         du[cnt].retardo_seg     = 0;
  69.         du[cnt].tiempo_seg      = 0;
  70.         du[cnt].cant_fichas_ins = 0;
  71.     }
  72.  
  73.     du[0].seleccionada = 1; // establece la primera como seleccionada
  74.  
  75.     contador_interrupciones_timer1 = 0;
  76.  
  77.     cronometro_refrigeracion = INTERVALO_REFRIGERACION_SEG;
  78.  
  79.     modo_programacion = 0; // 0 indica que no esta en el modo programacion
  80.  
  81. //##############################################################################
  82. //##############################################################################
  83. //##############################################################################
  84.  
  85. //    inicializar_valores(); // lo de arriba estaba en esta funcion
  86.  
  87.     RETARDO_500_MS;
  88.  
  89.     mostrar_datos_inicio();
  90.  
  91. //##############################################################################
  92. //##############################################################################
  93. //##############################################################################
  94.  
  95.     INTCONbits.RBIF = 1;
  96.     INTCONbits.INTF = 1;
  97.  
  98.     /**** INTERRUPCIONES ****/
  99.  
  100.     INTCONbits.PEIE  = 1; // Enables all unmasked peripheral interrupts
  101.     INTCONbits.RBIE  = 1; // Enables the RB port change interrupt
  102.  
  103.     // PORTB pull-ups are enabled by individual port latch values
  104.     OPTION_REGbits.nRBPU  = 1;
  105.     // Interrupt on rising (creciente) edge of RB0/INT pin
  106.     OPTION_REGbits.INTEDG = 1;
  107.  
  108.     INTCONbits.RBIF = 0;
  109.     INTCONbits.INTF = 0;
  110.  
  111.     INTCONbits.GIE   = 1; // Enables all unmasked interrupts
  112.  
  113.     T1CONbits.TMR1ON  = 1; // Timer1 On bit
  114.  
  115. //##############################################################################
  116. //##############################################################################
  117. //##############################################################################
  118.  
  119. //    activar_interrupciones_PORTB_TIMER(); // lo de arriba estaba en esta funcion
  120.  
  121.     PORTA = 0b00000000;
  122.     PORTC = 0b00000000;
  123.  
  124.     mostrar_en_display( LCD_EQUIPO_FUNCIONA_OK, 0 );
  125.  
  126.     emitir_sonido_general();
  127.  
  128.     while ( 1 )
  129.     {
  130.         ;
  131.     }
  132. }

antes, las porciones de código entre //#### estaban en funciones que llamaba desde el main, me marcaba el mismo warning

muchas gracias
Título: Re: XC8 - possible hardware stack overflow detected, estimated stack depth: 14
Publicado por: MerLiNz en 10 de Abril de 2014, 16:39:19
habria que ver el codigo completo ya que ese warning te lo da por llamar a funciones externas.
Título: Re: XC8 - possible hardware stack overflow detected, estimated stack depth: 14
Publicado por: PalitroqueZ en 10 de Abril de 2014, 20:12:49
según el aviso, tienes 14 llamadas de funciones anidadas y seguramente la línea 1083 es la línea donde llama la función numero 14 (de profundidad)
Título: Re: XC8 - possible hardware stack overflow detected, estimated stack depth: 14
Publicado por: LucasBols en 11 de Abril de 2014, 12:39:08
hola PalitroqueZ,

según el aviso, tienes 14 llamadas de funciones anidadas y seguramente la línea 1083 es la línea donde llama la función numero 14 (de profundidad)

la línea 1939 es la primer línea del main

saludos,
Título: Re: XC8 - possible hardware stack overflow detected, estimated stack depth: 14
Publicado por: LucasBols en 11 de Abril de 2014, 13:09:35
encontré la solución,

ISR --> m deep call

Microchip: estimated stack depth: 9 (http://www.microchip.com/forums/m703871.aspx)

Citar
PIC16F886
possible hardware stack overflow detected, estimated stack depth: 9
 
Solved if I use Linker~"Managed Stack".
 
I guess the problem is that if
   main -> n deep call
   ISR --> m deep call
the total possible depth is n+m.
 
Of course, if main only enables ISRs in main() itself (rather than deep inside some function calls) then less depth is "possible" - but the compiler does'nt know for sure so emits the warning.

muchas gracias,

saludos