1. Quick Introduction to Function Blocks

1. Quick Introduction to Function Blocks

1.1. Basic knowledge

If you want to know C language,Please click here

If you want to know editor,Please click here

1.2. 快速入门

  1. In the Engineering Explorer, right-click on the "Function Blocks" folder and open the context menu. Click "Add" → "Function Block".

![Add Function Block](./QuickStart~/Images~/pic11. png)

图1 Add Function Block

  1. When a "new function" appears, enter a suitable name.

![Rename](./QuickStart~/Images~/pic12. PNG)

图2 Rename

  1. Double click on "New Function" to open a blank text area. Enter C language code.

![Enter code](./QuickStart~/Images~/pic13. PNG)

图3 Enter code

  1. This C language function adds parameter a and parameter b, and writes parameter c. Parameters a and b are of type int, and parameter c is of type cword, which is actually an int pointer.

  2. Looking at the Engineering Resource Manager again, this function appears.

![Appearing Function](./QuickStart~/Images~/pic14. PNG)

图4 Appearing Function

  1. Drag the mouse to the editor and add the CALLM instruction that calls this function.

![Add CALLM](./QuickStart~/Images~/pic15. PNG)

图5 Add CALLM

  1. Fill in the parameters. Non pointer type parameters can be substituted into constants. The following program is equivalent to ADDD D0 K10 D2.

![Fill in parameters](./QuickStart~/Images~/pic16. PNG)

图6 Fill in parameters