Page 1 of 1

Serious Warning: 'FCD_RS2320_RS232_Delay'

Posted: Mon Feb 06, 2012 9:57 pm
by Mac
Has anyone had a compiler message that says "Serious Warning: Possible sw stack corruption, function 'FCD_RS2320_RS232_Delay' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)"?
I've had this warning for some time without ill effects as I built up the flowchart. Now, I think it may be a problem. I've tried to identify the cause of the warning, but haven't had any success. Any clues as to where to start looking would be greatly appreciated.
Thanks, Mac

Re: Serious Warning: 'FCD_RS2320_RS232_Delay'

Posted: Mon Feb 06, 2012 11:57 pm
by kersing
You are calling the listed macro from two places in your code. If both calls can occur at the same time the result is stack corruption.

Check you code for calls to the macro. If two of your own macros call this macro or the main program calls it and one of your macros calls it you should make sure the calls can not occur at the same time by restructuring your flowchart if necessary. One of the occurrences of the calls could be an interrupt routine.

You could try searching the forum for the "Serious Warning: Possible sw stack corruption" message as you are not the first to encounter this message.

Re: Serious Warning: 'FCD_RS2320_RS232_Delay'

Posted: Tue Feb 07, 2012 3:06 pm
by Benj
Hello,

I have found the cause of this bug and you can fix it yourself but only if you are using the RS232 Receive Interrupt. If you are using another interrupt to trigger the RS232 read byte macro then this fix will not work correctly.

Open the following file in a text editor
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_UART.c

Use the search function in your text editor to find this line (its on line number 553).
delay_us(10);

and comment it out.
//delay_us(10);

Save the file and the serious warning should disappear from your compilation messages.

Basically the error is occurring because the delay_us function is being called from somewhere in the Main and also somewhere in an interrupt probably via the rs232 receive function.

Let me know how you get on.

Re: Serious Warning: 'FCD_RS2320_RS232_Delay'

Posted: Tue Feb 07, 2012 3:08 pm
by Benj
Re-reading your original post are you using a software UART? If so then you may not be able to use this inside an interrupt. For this ignore the above and its probably better to set a flag in the interrupt and then process the flag in your main if possible.

Re: Serious Warning: 'FCD_RS2320_RS232_Delay'

Posted: Wed Feb 08, 2012 9:34 am
by Mac
Thanks Benj and Kersing,
I understand how calling a macro or other function from two different parts of the flowchart at the same time would be a problem.
I am only using one RS232 receive component macro and it's in the MAIN, inside a loop where I call a UART macro and SUM the ASCII numbers. When I first posted my problem, I had a custom RS232 interrupt in the main. When I removed it, one of my SERIOUS WARNINGS went away and the RS232 kept working. Should I put it back in and use your first suggestion and comment out delay_us(10); ? I am using software UART, but I don't know the difference between it and UART1. I'll switch and see what happens.
I'll have to read up on setting a flag. "dah"
There are a lot of details I don't know, as you can see.
Thanks Again, Mac

Re: Serious Warning: 'FCD_RS2320_RS232_Delay'

Posted: Wed Feb 08, 2012 10:19 am
by Mac
Hello Benj,
I changed the RS232 properties from software to UART1, downloaded the flowchart into the chip and did not get any SERIOUS WARNING messages using V4.
Lots of Thanks. :D
Mac

Re: Serious Warning: 'FCD_RS2320_RS232_Delay'

Posted: Thu Feb 09, 2012 3:58 pm
by Mac
Hello Matrix Team,
The above fix worked for both Flowcode V4 and V5. I now have RS232 receive capability using V5, (My problem in a previous post) but I still get the Serious Warning: Possible sw stack corruption, function 'delay_us' .
The //delay_us(10) fix worked for V5 to clear up the Serious Warning: Possible sw stack corruption, function 'delay_us', but I lose both RS232 send and receive capability. I put the delay_us (10) back in so I could continue working with V5, but with the warning.
Thanks, Mac