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. For Flowcode v7 and above, the case of the macro names much match.

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 and use all upper case, e.g.

asm("MOVLW 0x04");


or enclose several statements within an asm block, tow methods can be used for PIC8 Either

#asm
MOVLW 0x04
MOVWF TRISA
#endasm

Or

asm("MOVLW 0x04");
asm("MOVWF TRISA");


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.