Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12604 Discussions

"Use separate stack for interrupts" corruption?

Altera_Forum
Honored Contributor II
1,140 Views

Hi! 

 

I have a program that runs on a NiosII, with 5 threads, and 2 interrupt sources (interrupting every 10 seconds, very slow). 

 

The fact is that I don't check the "Use separate stack for interrupts" in "eCos HAL" -> "HAL interrupt handling" in eCos lib generation, my program crashes. 

 

Sometimes it says is a stack corruption, sometimes is an assert in the scheduler code... 

 

I think suppose that, with this few interrupt sources, this data corruption shouldn't occur... but it does... I've also tried it without generating anyinterrupt (except the timer, obviously), and it's the same. 

 

Any idea about why is it happening? 

 

Thank you 

 

Alex Bueno
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
332 Views

It could be that you really have got a stack overflow. Have you checked your stack usage/tried to increase the stack size on the threads involved?

0 Kudos
Altera_Forum
Honored Contributor II
332 Views

It could be. I've found that if I activate "Save minimum context on interrupt", ISR process faster, and also data corruption seems to happen in less situations. With this option activated, the default ISR vector reduces the register saving in 140 bytes, thus using less stack. It seems coherent. 

 

Today I've found that part of my data corruption was due to some static buffers being written in a wrong way. This is, mora data than the length of the buffer, he he. 

 

Also there was a function that had a memory leak (which wasn't written by me), so you can imagine the mix of both problems. 

 

Thank you for all. 

 

Alex
0 Kudos
Reply