Page 1 of 1

Jump from a Macro to Main

Posted: Sat Apr 14, 2007 8:34 pm
by janleroux
Hi

According to the help file: "To jump to a connection point called A, defined in a Flowcode macro called TEST, you C code must be goto FCC_TEST_A;. Connection points defined in the main flowchart of a Flowcode file are prefixed FCC_Main_."

If I try it, then I get the following error:
error: undefined label 'FCC_Main_C'
This is what I have done:
I have created a connection point called "C" right in the beginning of my "Main". From a macro I am using the following code in a C Code box:

Code: Select all

goto FCC_Main_C;


I had a look through the forums, but I could not find any similar examples. Is there some additional code that is not mentioned by the help file that is required, or is this a bug?

Thanks for your help!

Best Regards
Jan

Posted: Mon Apr 16, 2007 9:25 am
by Steve
It is not a good idea to jump between macros in this way - you should organise your program in a different way.

Flowcode "macros" are subroutines. If you jump between subroutines, then the PICmicro's internal return address stack will become corrupted and your program will start behaving strangely.

Posted: Mon Apr 16, 2007 9:50 am
by janleroux
Hi Steve,

I understand, but the jump that want to make is to take me right to the beginning of my main routine - everything will be re-initialized etc.

Is there another way to perform a software reset?

Regards
Jan

Posted: Mon Apr 16, 2007 10:13 am
by Steve
If you are using an 18F series PICmicro, you can use the ASM command "reset" - this will perform a soft reset.

Alternatively, you should do something similar to the following in a 'C' icon:

Code: Select all

_asm 
{
  clrf    _intcon
  clrf    _status
  clrf    _pclath
  clrf    _pcl
}