Estoy desarrollando un proyecto en Flowcode v10 para un microcontrolador PIC16F876A. El proyecto incluye un sensor de temperatura (termistor), visualización por LCD I2C (LCM1602), y una rutina de temporización basada en interrupciones.
Al compilar, recibo la siguiente advertencia del compilador XC8 (v2.10):
(1393) possible hardware stack overflow detected; estimated stack depth: 9
Entiendo que el PIC16F876A solo soporta 8 niveles de stack por hardware, por lo que esta advertencia es relevante.
El comportamiento es el siguiente:
Si elimino tres interrupciones (o las macros asociadas), la advertencia desaparece.
Si mantengo la lógica principal, pero sin interrupciones, el proyecto compila sin problemas.
Las interrupciones eliminadas contenían lógica relativamente simple, como incrementar un contador y verificar si timer == 305 para incrementar una variable seg_base.
Sin embargo, parece que Flowcode 10 encapsula estas funciones de forma más profunda que Flowcode 9, ya que en Flowcode 9 no recibo la advertencia, aún usando el mismo compilador XC8 v2.10.
Mis preguntas son:
¿Flowcode v10 genera más niveles de función internamente al trabajar con interrupciones?
¿Existe una forma segura de implementar temporización por interrupciones sin exceder los niveles de stack?
¿Hay alguna configuración o práctica recomendada para evitar este tipo de advertencias en microcontroladores con pila limitada?
Agradecería mucho cualquier orientación para mantener el uso de interrupciones sin comprometer la estabilidad ni recibir advertencias críticas.
Advertencia de posible desbordamiento de pila (stack overflow) al usar interrupciones en PIC16F876A
-
- Posts: 1
- http://meble-kuchenne.info.pl
- Joined: Tue Sep 07, 2021 12:36 am
-
- Valued Contributor
- Posts: 1609
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 357 times
- Been thanked: 565 times
Re: Advertencia de posible desbordamiento de pila (stack overflow) al usar interrupciones en PIC16F876A
I used google translate on the above
Translation
I'm developing a project in Flowcode v10 for a PIC16F876A microcontroller. The project includes a temperature sensor (thermistor), visualization by LCD I2C (LCM1602), and a timing routine based on interruptions.
When compiling, I received the following warning from the XC8 compiler (v2.10):
(1393) possible hardware stack overflow detected; estimated stack depth: 9
I understand that the PIC16F876A only supports 8 stack levels per hardware, so this warning is relevant.
The behavior is as follows:
If I eliminate three interruptions (or associated macros), the warning disappears.
If I maintain the main logic, but without interruptions, the project compiles without problems.
The eliminated interruptions contain relatively simple logic, such as incrementing a counter and checking if timer == 305 to increment a seg_base variable.
However, it seems that Flowcode 10 encapsulates these functions more deeply than Flowcode 9, since Flowcode 9 does not receive the warning, even using the same XC8 v2.10 compiler.
My questions are:
Translation
I'm developing a project in Flowcode v10 for a PIC16F876A microcontroller. The project includes a temperature sensor (thermistor), visualization by LCD I2C (LCM1602), and a timing routine based on interruptions.
When compiling, I received the following warning from the XC8 compiler (v2.10):
(1393) possible hardware stack overflow detected; estimated stack depth: 9
I understand that the PIC16F876A only supports 8 stack levels per hardware, so this warning is relevant.
The behavior is as follows:
If I eliminate three interruptions (or associated macros), the warning disappears.
If I maintain the main logic, but without interruptions, the project compiles without problems.
The eliminated interruptions contain relatively simple logic, such as incrementing a counter and checking if timer == 305 to increment a seg_base variable.
However, it seems that Flowcode 10 encapsulates these functions more deeply than Flowcode 9, since Flowcode 9 does not receive the warning, even using the same XC8 v2.10 compiler.
My questions are:
- Does Flowcode v10 generate higher levels of function internally when working with interruptions?
Is there a safe way to implement interruption timing without exceeding stack levels?
Is there any configuration or recommended practice to avoid this type of warnings on microcontrollers with limited power?
-
- Valued Contributor
- Posts: 1554
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 138 times
- Been thanked: 740 times
Re: Advertencia de posible desbordamiento de pila (stack overflow) al usar interrupciones en PIC16F876A
Interrupt routines should (always) be short and as quick as possible - usually not calling other macros, but certainly not calling things such as displaying data.
If your interrupt is something like:
Then it is probably not the source of the issue.
Do you have any recursive calls in any of your other code..
It's very hard to debug without seeing the code - do for more help please post some code that demonstrates the error.
Martin
If your interrupt is something like:
Code: Select all
time=time+1
If time = 405
Flag = true
time=0
Do you have any recursive calls in any of your other code..
It's very hard to debug without seeing the code - do for more help please post some code that demonstrates the error.
Martin