Serious Warnings

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Xavier
Posts: 99
Joined: Sat Mar 17, 2012 11:26 pm
Location: South Africa
Has thanked: 5 times
Been thanked: 3 times
Contact:

Serious Warnings

Post by Xavier »

Could you tell me why in one flowcode using Osccon and a call macro I have no serious warnings yet in the other using an interrupt (calling the same macro) and osccon I get three serious warnings? i just have not been able to figure it out for myself, believe me I did try but I'm obviously barking up the wrong tree.

Serious Warning: Possible sw stack corruption, function Wdt_Delay_Ms' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'FCD_LCDDisplay0_RawSend' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'delay_ms' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)

Could you also clear up a few thing for me please

What is Wdt?
What is Ms? milliseconds? and ms? microseconds?
What is FCD? FlowCode display?
Is there a list with all these abbreviations?
Why do I keep getting this.... Pi_Detecor_Timer.fcf.001? instead of just Pi_Detecor_Timer.fcf? every time that I want to upload a FlowCode I have to battle renaming things.


All the very best
Xavier
Attachments
PI_Detector_Timer.fcf
(27.84 KiB) Downloaded 250 times
PI_Detector_Timer_b (2).fcf
(28.19 KiB) Downloaded 260 times

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 Warnings

Post by kersing »

Xavier wrote: What is Wdt?
What is Ms? milliseconds? and ms? microseconds?
What is FCD? FlowCode display?
Is there a list with all these abbreviations?
Why do I keep getting this.... Pi_Detecor_Timer.fcf.001? instead of just Pi_Detecor_Timer.fcf? every time that I want to upload a FlowCode I have to battle renaming things.
Wdt is watchdog timer. Can be disabled in the configuration settings.
FCD is Flowcode controller definition. These files contain controller specific information.
The .001 files are backup files, every time you save the file the previous version is saved with the .001 extension.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

Re: Serious Warnings

Post by Kenrix2 »

Although kersing is correct that wdt is generally used as an abbreviation for watch dog timer, in this particular case it is referring to a delay function. You can view this function in the file PIC_CAL_Delay.c if you like, it is just a delay similar to the delay icon. Flowcode has many behind the scene functions to make our programing experience so easy (which is why I like Flowcode so much). ms is milliseconds (.001),one thousand milliseconds = one second, us is microseconds (.000001), one million microseconds = one second. As to your programs, good job in proving Medelec's rules
Well you can call a macro form another macro so long as

1. Your not calling a macro from an interrupt macro
2, The second macro is allowed to exit at the bottom of the macro.
3. Very important: Number of stacks are not exceeded (You will get a warning about this during compiling. Just remember its not just going into macros that will cause stacks to increase, stack will increase with going to to each component, but will decrease again when back out of the component etc), then you can call even more macros from with in macros, but never call any of the macros that have got you into your current macro if you know what I mean?
in this post: http://www.matrixmultimedia.com/mmforum ... 46&t=14095
Also, it is almost always required to have your osccon value to be placed at the very beginning of you program since timings (like Wdt_Delay_Ms) are based upon the actual microcontrollers clock speed which has to be the same as the value you enter into the project options.

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 Warnings

Post by kersing »

In this case Wdt is also used for watchdog timer. The function Wdt_Delay_Ms is a delay function (milliseconds) with automatic watchdog reset. Normally if you enable the watchdog timer and use a delay the watchdog might trigger due to it not being reset while the delay is active. To prevent this from happening Flowcode automatically uses a delay with watchdog reset when the watchdog is active in the project settings.

Generally speaking, I would recommend to disable the watchdog in project settings and chip settings for all projects as it complicates the software. Only enable it when absolutely required.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Xavier
Posts: 99
Joined: Sat Mar 17, 2012 11:26 pm
Location: South Africa
Has thanked: 5 times
Been thanked: 3 times
Contact:

Re: Serious Warnings

Post by Xavier »

Thanks guys

I will have a go at getting thing right now that I understand where the problems are :D

All the best
Xavier

Xavier
Posts: 99
Joined: Sat Mar 17, 2012 11:26 pm
Location: South Africa
Has thanked: 5 times
Been thanked: 3 times
Contact:

Re: Serious Warnings

Post by Xavier »

kersing wrote: Generally speaking, I would recommend to disable the watchdog in project settings and chip settings for all projects as it complicates the software. Only enable it when absolutely required.
OK I disable the Wdt in the chip configuration but I can't seem to find the project settings, could you tell me where it is please?

Regards
Xavier

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 Warnings

Post by kersing »

"Build" -> "Project options", Tab "General Options". Make sure "Auto clear watchdog" is not set.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Xavier
Posts: 99
Joined: Sat Mar 17, 2012 11:26 pm
Location: South Africa
Has thanked: 5 times
Been thanked: 3 times
Contact:

Re: Serious Warnings

Post by Xavier »

OK well did that but my problem is still there.
Serious Warning: Possible sw stack corruption, function 'Wdt_Delay_Ms' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)

And this one I have not been able to solve yet. I have LCD start in Main and I have a call macro LCD_Update at the end of macro Start...what more can I do :? Also could you tell me what is meant by RawSent?
Serious Warning: Possible sw stack corruption, function 'FCD_LCDDisplay0_RawSend' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)

And when I have auto clear Wdt then this one goes away
Serious Warning: Possible sw stack corruption, function 'delay_ms' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)

Kind regards
Xavier
Attachments
Timer_D.fcf
(12.73 KiB) Downloaded 261 times

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Serious Warnings

Post by dazz »

HI
the raw send is the name of one of the commands in the component used for sendng a command to lcd,
one of the others is because you are calling a macro from a macro in int, try moving the lcd update macro to your loop as the update should only change after the int macro has run.

im a bit pressed for time but if your int macro was say count based the your int macro could be something along the lines of

count =count+1
if count >10
yes variable =1
count =0
no continue

then in main you could have
if variable =1 call macro

not the best or most elegant solution but should work

regards
dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

Xavier
Posts: 99
Joined: Sat Mar 17, 2012 11:26 pm
Location: South Africa
Has thanked: 5 times
Been thanked: 3 times
Contact:

Re: Serious Warnings

Post by Xavier »

Thanks for the prompt reply Dazz I will see is I can get that to work.

All the best
Xavier

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Serious Warnings

Post by dazz »

hi
cool i cant have a look till sometime tommorow but if you post an up to date chart i will find some time to have a quick look

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

Xavier
Posts: 99
Joined: Sat Mar 17, 2012 11:26 pm
Location: South Africa
Has thanked: 5 times
Been thanked: 3 times
Contact:

Re: Serious Warnings

Post by Xavier »

Thanks Dazz

I have moved the LCD_Update all over the place and the problem is still there. I will continue to try and solve the problems till I post the updated chart sometime tomorrow morning.

Regards
Xavier

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 Warnings

Post by kersing »

Hi Xavier,

Looking at your code I notice the following:
  • - Enable interrupt in a loop. There is no need to enable the interrupt in a loop, it only needs to be enabled once. (Except when disabled)
    - The same applies to setting C5 in the Start macro. Set it to 1, then loop (or better, use delay) the output will not change during the loop.
    - You are using LCD calls in a macro called from an interrupt macro. Not a good idea. LCD macros have delays in them causing conficts like the ones you are seeing
    - LCD_Update will always display 3500 as it displays On_Count which is counted up to 3500 in the Start macro.
    - Your interrupt frequency is 7812.5 Hz, so the macro Start should be called over 7000 times a second. Yet you use a 1 second delay in Start.
When an interrupt routine is active all new interrupts are ignored. Only when the routine is finished a new interrupt can be handled. All interrupts of the same kind that have occurred during execution of handler are lost.

Generally rules for interrupts (as always there are exceptions to these rules):
  • - Enable interrupts once.
    - Do not call macros in interrupt routines.
    - Always return from an interrupt as soon as possible.
    - Never use delay statements in interrupts.
Attached a version of you code that compiles without errors.

Jac
Attachments
Timer_D.fcf
(15.5 KiB) Downloaded 179 times
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Xavier
Posts: 99
Joined: Sat Mar 17, 2012 11:26 pm
Location: South Africa
Has thanked: 5 times
Been thanked: 3 times
Contact:

Re: Serious Warnings

Post by Xavier »

Hi Kersing

Thanks for your help, the way that I understand the If Intr_Occured is that it works like a counter, you have it as <>0 then at the end of the macro you have it as =0, that would reset it but why not just use a count? if count is = 1 then and at the end of the macro count = 0 , am I missing something? in fact looking at it, there is no use to have the macro Start at this point in time either is there?

Hi Dazz

I did not upload the updated version of my flow chart yet because it's far from ready not to mention that I thing that I took on more that I can chew on LOL.

All the best
Xavier

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Serious Warnings

Post by dazz »

Hi Xavier
don't we all lol, we all bite of more than we can chew, when i get into that situation i try to work out 1 piece of the puzzle at a time and save it i then add the next bit and save under a different name so you have copies of each step

a way to look at interrupts is as follows (note im using general anologys)
You may need to do three things (1 )open a door ,(2)close a door,(3) if the door is not shut in 2 seconds, shout at whoever left it open, in a microcontroller it will progress through those tasks in an sequential fashion ie
1,2,3 . that looks ok but and heres the but one of the numbers is time critical ie number 3 (hey we all love a good shout), that sequence will repeat over and over and has to finish before it can get back to number 3.
A way around this is an interrupt as the second the door is opened it can count to two then start shouting ,once its finished shouting it goes back to the main code where it left off.
this is because an interrupt works independently of your main sequence above and quietly works away waiting to spring into action,once sprung it carries out its task and stays doing it till its finished, then it it will sit waiting to trigger again. hope that makes sense as i know its a simplistic explanation and there's more to it.
If you look at the chart kersing did the interrupt counts to 7800(ish) in one second at that point it starts again, but its also called the start macro and set int_occurred variable to one, so now your main code will run that decision branch as the variable is now 1 this also includes a loop to count to 3500 after that it updates the display ,and also resets the count and int_occurred to 0, but as its actioning an interrupt it wont action anymore interrupts till this one completes. then its free to do it again if an interuppt occurs or run the code

hope it helps

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

Xavier
Posts: 99
Joined: Sat Mar 17, 2012 11:26 pm
Location: South Africa
Has thanked: 5 times
Been thanked: 3 times
Contact:

Re: Serious Warnings

Post by Xavier »

Hi Guys

OK I need to get a printer LOL Thanks Dazz I'm going to use this information to the best of my ability. I think that I'm going to start fresh all over again and apply what you guys have told me, I'm also going to reduce the size of the flow chart after all it really is repetition once the first part is working like it should. On time, delay time, sample time and another delay that determines the frequency or PPS

All the best
Xavier PS you'll probably hear form me sooner than later LOL

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 Warnings

Post by kersing »

Xavier wrote:the way that I understand the If Intr_Occured is that it works like a counter
No it is a flag. Every second the timer interrupt will call Start 7812 times. In Start the flag is set to one. Then in the main loop the test checks if the flag is non zero (it is after one interrupt) and executes the code you originally had in the Start macro. Afterwards it sets the flag to zero to signal no (new) interrupt occurred AFTER executing your code. While your code is executing the timer is still generating 7812 interrupts a second, so Start is called and intr_occurred is set to 1. But as it is 1 this makes no difference. Once it is reset to 0 it will almost immediately be set to 1 as within 1/7812th of a second a new interrupt will be generated. (Within because the previous one might have occurred almost the same amount of time ago)
Xavier wrote:you have it as <>0 then at the end of the macro you have it as =0, that would reset it but why not just use a count? if count is = 1 then and at the end of the macro count = 0 , am I missing something? in fact looking at it, there is no use to have the macro Start at this point in time either is there?
Without Start the intr_occurred will not be set, so you code will not be executed. Why not re-use count? Because I have no idea what you are trying to achieve and I just wanted to show a better way to use the interrupt code. Small amount of code taking only a small amount of time to execute in the interrupt handler and the time consuming code with macro calls in the main loop.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Xavier
Posts: 99
Joined: Sat Mar 17, 2012 11:26 pm
Location: South Africa
Has thanked: 5 times
Been thanked: 3 times
Contact:

Re: Serious Warnings

Post by Xavier »

Thanks Kersing

All this information is going to take some time to sink in but I'll get it in the end. I'm now trying to get a flow chart to work without any errors still aimed at the same thing. Ho by the way the flow chart is for a PI metal detector, I need to set the on time the delays and so on not to mention that I want to be able to write and read to the eeprom.

All the best
Xavier

Xavier
Posts: 99
Joined: Sat Mar 17, 2012 11:26 pm
Location: South Africa
Has thanked: 5 times
Been thanked: 3 times
Contact:

Re: Serious Warnings

Post by Xavier »

Hi Guys

Well I have been trying to follow your instructions to the letter but that is not an easy thing to do, yet I now have a flow chart with no errors so I must be doing something right, :) however my flow chart looks like a young boy's untidy room, also I find the program slow. So before I get all exited could you please have a look at my flow chart and let me know what I should do to make it better?

All the very best
Xavier
Attachments
Timer_E.fcf
(25.32 KiB) Downloaded 174 times

Post Reply