Page 1 of 1

Possible SW Stack Corruption

Posted: Fri Mar 22, 2013 3:03 am
by jethronull
I've had a few of these warnings rush past without me noticing them till recently. Specifically I am getting:
Serious Warning: Possible sw stack corruption, function 'FCI_GETLENGTH' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'FCI_MIDSTRING' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'FCI_NUMBER_TO_HEX' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'FCI_SHEAD' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'FCI_SCOPY' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'delay_us' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Now I thought I was being pretty careful not to put any macros in my interrupt routine but it is pretty hard to avoid using Flowcode's own macros. There is a genuine likelihood of one of these chaps colliding, though I am not sure whether it has happened or not (Ben, could this be the source of some of my RS232 and Flowkit weirdness?). This just seems odd to me though. Is the compiler worrying unnecessarily about built-in macros? If this is really a concern then the only solution I can think of is to go back to polling the RS232 instead of calling it by interrupt, which is of course, the preferred way to handle serial comms.

Re: Possible SW Stack Corruption

Posted: Fri Mar 22, 2013 10:44 am
by Benj
Hi Jon,

Yep that could be doing it. It looks like because your using the string manipulation functions in your interrupt routine and also inside your main loop then as you say there is the high likelihood of a clash. You can still receive characters using the RXINT but would it be possible to set a variable that then gets picked up in your main program loop to do the string processing etc on the received data.

Re: Possible SW Stack Corruption

Posted: Sat Mar 23, 2013 12:25 am
by jethronull
Since using ReceiveRS232String only seems to work with ASCII data I can't use that (am I correct about that or am I missing something?). Could I cycle round ReceiveRS232Char feeding the incoming bytes into a int array? Then deal with the processing outside the interrupt. Or would I need to take one char at a time, exit the interrupt and concatenate outside? The latter would need nothing but a .Return in the interrupt, but the concatenation would probably get interrupted by the next RX byte.

BTW, did you know that the ReceiveRS232String definition in the help file actually calls it ReceiveRS232Char (little cut a paste error there).

Thanks.