Serious Warning: 'FCD_RS2320_RS232_Delay'

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Mac
Flowcode V4 User
Posts: 23
Joined: Mon Jul 18, 2011 8:31 pm
Has thanked: 6 times
Been thanked: 2 times
Contact:

Serious Warning: 'FCD_RS2320_RS232_Delay'

Post 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

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Serious Warning: 'FCD_RS2320_RS232_Delay'

Post 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.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Serious Warning: 'FCD_RS2320_RS232_Delay'

Post 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.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Serious Warning: 'FCD_RS2320_RS232_Delay'

Post 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.

Mac
Flowcode V4 User
Posts: 23
Joined: Mon Jul 18, 2011 8:31 pm
Has thanked: 6 times
Been thanked: 2 times
Contact:

Re: Serious Warning: 'FCD_RS2320_RS232_Delay'

Post 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

Mac
Flowcode V4 User
Posts: 23
Joined: Mon Jul 18, 2011 8:31 pm
Has thanked: 6 times
Been thanked: 2 times
Contact:

Re: Serious Warning: 'FCD_RS2320_RS232_Delay'

Post 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
Last edited by Mac on Thu Feb 09, 2012 3:59 pm, edited 1 time in total.

Mac
Flowcode V4 User
Posts: 23
Joined: Mon Jul 18, 2011 8:31 pm
Has thanked: 6 times
Been thanked: 2 times
Contact:

Re: Serious Warning: 'FCD_RS2320_RS232_Delay'

Post 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

Post Reply