# &flowcode;

## Introduction

&flowcode; allows for very quick and easy construction of a PIC program. After the user has constructed a flowchart from the program parts available, &kappname; can then convert the flowchart into a number of formats. To output hex, for example, the following chain of conversions takes place:

1. The &flowcode; is converted to &microbe;; a high-level language whose compiler is distributed with &kappname;.

2. The `microbe` executable then compiles the &microbe; file to PIC assembly.

3. Finally, `gpasm` takes the PIC assembly file, and outputs the hex for the program.

Of course, if you don't have gputils installed - with which `gpasm` is distributed - then the last step can't be performed.

## Creating a Program

Every &flowcode; program needs a unique starting point - this is the place where your program will be run from on PIC startup. To define this point, open up the FlowParts sidebar on the left, and drag across the Start part. &kappname; will only allow you to use one of these.

You can then construct your program by using the predefined parts on the left - or insert code of your own (in assembly or &microbe; format) via the Embed part. The flow of the program is controlled via the connections between the FlowParts - offers more detail on creating connections.

&flowcode; imposes limitations in addition to those of Circuits on what can be connected. For example, each FlowPart can only have one output connection. Additional limitations are described in .

## PIC Settings

When you create a new &flowcode; document, you'll notice a picture of the PIC you're using in the top-left corner of the work area. This represents the initial settings of the PIC.

Each pin shown on the picture of the PIC shows the initial type of pin (input or output), and its initial state (high or low). You can change these by dragging the pin to set the type, and clicking on it to toggle its state.

The Settings dialog, invoked by clicking on the Settings button, also allows you to edit the initial pin types and states - in this case, by editing the binary values written to the PORT and TRIS registers. As well as pin settings though, the dialog allows editing of the initial values of variables in the PIC program.

At the bottom, there is a list of currently defined pin maps, as well as buttons to manipulate them. Pin maps are used to specify how a seven segment or a keypad is connected to a PIC. To use the Seven Segment or the Keypad &flowcode; parts, you will need to define a pin map here first.

## Nestling &flowcode;

Many FlowParts, such as subroutines and loops, can contain code of their own. After creating such a container, FlowParts can be added by either dragging or dropping them into the container. The container will be highlighted to indicate that it will become the new parent of the FlowPart.

The container takes responbility for FlowParts nestled inside. If the expand button is unclicked, all contained FlowParts will be hidden - and likewise, the contents will be shown when the expand button is clicked again. Connections cannot be made between FlowParts in different containers, and the contents of a container will be moved about along with the container.