HW Stack Overflow on MC56F8035

cancel
Showing results for 
Search instead for 
Did you mean: 

HW Stack Overflow on MC56F8035

Jump to solution
279 Views
petercernan
Contributor I

Hello, I'm working on solar microinverter with MC56F8035 DSC. I  use Quickstart / CW 5.9.0 for software development. I faced the issue with HW stack overflow. My program includes ADC converter and Timer A0 controlled by coresponding interrupts (level 1/level2). Both interrupt service routines and its subfunctions use # pragma interrupt on/off to store/restore data/registers correctly. I reviewed linker command file SDM_pflash.cmd where stack size is defined. I increased it from 0x100 to 0x200 but there was no improvement, HW stack overflow occured again. Any idea what's wrong? Thanks in advance for your advise. Have a nice day. Peter

Labels (1)
0 Kudos
1 Solution
182 Views
johnlwinters
NXP Employee
NXP Employee

I have not seen the source code but at first glance it seems that the interrupt handler is defined incorrectly.

Interrupt handler definition using

“#pragma interrupt on/off”

can only be used when

the interrupt handler does not call any function/routine and

entire “raw” source code is written inside the interrupt handler.

If at least one function is called from the interrupt handler, the definition above leads to software crash and the HW stack overflow condition.

Solution: Use “#pragma interrupt saveall” before the interrupt handler definition.

Example of correct definition of the interrupt handler:

#pragma interrupt saveall

void HandlerISR(void)

{

/* user source code including function calls */

}

View solution in original post

0 Kudos
2 Replies
183 Views
johnlwinters
NXP Employee
NXP Employee

I have not seen the source code but at first glance it seems that the interrupt handler is defined incorrectly.

Interrupt handler definition using

“#pragma interrupt on/off”

can only be used when

the interrupt handler does not call any function/routine and

entire “raw” source code is written inside the interrupt handler.

If at least one function is called from the interrupt handler, the definition above leads to software crash and the HW stack overflow condition.

Solution: Use “#pragma interrupt saveall” before the interrupt handler definition.

Example of correct definition of the interrupt handler:

#pragma interrupt saveall

void HandlerISR(void)

{

/* user source code including function calls */

}

View solution in original post

0 Kudos
182 Views
petercernan
Contributor I

Hello John,

first of all, thank you very much for your advice. It works!

You are right, my interrupt service routines included subfunctions.

HW stack overflow didn't occur again once I changed all the ISR's to "#pragma interrupt saveall" (while keeping subfunctions called by ISR's with “#pragma interrupt on/off”).

Have a nice day

Peter

0 Kudos