C Code Icon Properties

From Flowcode Help
Jump to navigationJump to search

<sidebar>Sidebar: Icon Properties</sidebar>

Btn C Code.gif Gen C Code Flowchart Icon.png Gen C Code Icon Properties.png

Flowcode is designed to allow those new to microcontroller programming to design programs with little knowledge of other programming languages. However it is possible to embed code written in other languages into Flowcode programs. Programs written in C and Assembly code can be embedded in Flowcode using the Code icon. This means that it is possible to take complex programs (you will find lots of programs on the internet) written in C or assembly and embed them into your designs.


The code can not be simulated by Flowcode, but is passed on to the microcontroller during compilation.


Display Name

The name of the icon that appears on the flowchart.


Variable Box

Quickly browse the variables defined in your project. You can reference ports directly or select from a list of available Global or Local variables. Dragging and dropping the variables into the C Code box will automatically add the correct Flowcode specific prefix.


C Code

Enter any C code you wish to include in the flowchart. The C code is not checked by Flowcode but is passed straight to the C compiler when the flowchart is compiled. It is important to verify that the C code entered is correct, as syntax errors will cause the compilation of the whole flowchart to fail.


To access Flowcode variables, macro functions and connection points, it is necessary to color the variable in your C code with the prefixes FCV_, FCM_ and FCC_MacroName_ respectively.


For example, to use a Flowcode variable called DELAY in your C code, you must refer to it using FCV_DELAY

Note that all Flowcode defined variables are upper case.


To call a Flowcode macro called TEST in your C code, you must call FCM_TEST();

Note that for Flowcode versions up to Flowcode 6, all Flowcode macro names are upper case.


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


Assembly Code

Assembly code can be added into the code field in a C assembly code wrapper.


For a single line of code use the asm operator in front of each instruction, e.g.

asm movlw 5


or enclose several statements within an asm block:

asmTo access Flowcode variables, macro functions and connection points, it is necessary to further color the prefixes used above with a preceding underscore, _FCV_, _FCM_ and _FCC_MacroName_ respectively.


The examples used above now become _FCV_DELAY, _FCM_TEST() and _FCC_TEST_A.


Video instructions

See the Custom code video to learn how to add custom C code to the flowchart using the C Code icon to set the value of a variable to 0.

{{#ev:youtube|JgjQlV6LQYI|640}}