Conversion FC5/6 to Flowcode 7 that contains C code

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3451 times
Contact:

Conversion FC5/6 to Flowcode 7 that contains C code

Postby medelec35 » Tue Jul 05, 2016 4:50 pm

Before compiling Flowcode V7 that has been loaded with Flowchart from Flowcode V5 or Flowcode V6 you must convert C code from BoostC to XC8 as that is what's shipped with Flowcode V7
In Boost C lower case is used for register and uppercase for bits.
In XC8 Upper case is used for both.
Examples

Code: Select all

BoostC  (Up to FC6)         XC (FC7)
osccon = 0x70;              OSCCON = 0x70;
st_bit(iocap,IOCAP3);     st_bit(IOCAP,IOCAP3); or set_bit(IOCAP,IOCAP3)

If bit is a NOT bit, for example to enable weak pullups the register bit could have a bar above:
Option Register.jpg
Option Register.jpg (8.01 KiB) Viewed 7764 times

Then you need to place a lower case n preceding the bit name.
for example to enable weak pull-ups on 16F1825 you will need to use:

Code: Select all

clear_bit(OPTION_REG,nWPUEN); or  cr_bit(OPTION_REG,nWPUEN)

Or you can use

Code: Select all

OPTION_REGbits.nWPUEN = 0;


If I find any more examples I will post them.
These users thanked the author medelec35 for the post (total 11):
Steve (Tue Jul 05, 2016 4:56 pm) • Rudi (Tue Jul 05, 2016 5:33 pm) • kersing (Tue Jul 05, 2016 7:17 pm) • Zane (Tue Jul 12, 2016 8:44 pm) • lordhex (Fri Jul 29, 2016 6:45 pm) • Benj (Tue Aug 23, 2016 11:24 am) • EtsDriver (Wed Nov 23, 2016 10:44 pm) • chipfryer27 (Fri Apr 21, 2017 12:53 pm) • jgu1 (Fri Jun 09, 2017 5:41 am) • jadiflow (Thu Jun 22, 2017 12:37 pm) and one more user
Rating: 57.89%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

millsk3
Posts: 2
Joined: Sat Aug 20, 2016 11:41 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Conversion FC5/6 to Flowcode 7 that contains C code

Postby millsk3 » Sat Aug 20, 2016 11:57 pm

I am learning how to use Flowcode 7 using the book: Create 30 PIC Microcontroller Projects with Flowcode 6. Most of the projects work without problems and the only ones that don't work are those with C Code.
I have no knowledge of C Code, so could someone help me to convert the C Code so it works in Flowcode 7. The one I am looking at is : FCV_FROMTABLE = ATF [FCV_POSITIONINTABLE] ;
It would be good if Matrix could provide a list of examples for the commonly used C Code or even an update of the files which support this book.
Thank you.
Regards
Ken

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3451 times
Contact:

Re: Conversion FC5/6 to Flowcode 7 that contains C code

Postby medelec35 » Tue Aug 23, 2016 11:38 am

Hi Ken,
It looks like the formation of a lookup table in C since FCV is just FlowCode Variable.
So it was just retreving a value from an array.
That's what the square brackets mean - [] = array

Since from Flowcode V6 there is a lookup table component you can use that instead of C code.
For help on lookup table component see here
Just to make sure if you post your flowchart I can take a look.

Martin
These users thanked the author medelec35 for the post (total 2):
millsk3 (Tue Aug 23, 2016 8:22 pm) • Benj (Wed Aug 24, 2016 11:42 am)
Rating: 10.53%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

millsk3
Posts: 2
Joined: Sat Aug 20, 2016 11:41 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Conversion FC5/6 to Flowcode 7 that contains C code

Postby millsk3 » Tue Aug 23, 2016 8:20 pm

Martin,

Thank you very much. I have substituted the lookup table as you suggested and it now works properly, this also allows me to use the simulation function.

Ken
These users thanked the author millsk3 for the post:
Benj (Wed Aug 24, 2016 11:42 am)
Rating: 5.26%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3451 times
Contact:

Re: Conversion FC5/6 to Flowcode 7 that contains C code

Postby medelec35 » Tue Aug 23, 2016 9:39 pm

Hi Ken,
Glad your all sorted.
Thanks for letting us know.

Martin
These users thanked the author medelec35 for the post:
Benj (Wed Aug 24, 2016 11:42 am)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.