Contents
Contents:
Introduction
Getting Started
Working with flowchart files
Creating and editing flowcharts
Adding and editing components
Working with macros and variables
Simulating a flowchart
Compiling flowcharts to Chips
Virtual Networks
Introduction
Introduction
New In Version 4
Chips
Technical Support
Getting Started
Developing a flowchart for a Chip
Flowcode's tools and views
Zooming the view
Selecting a target chip
Project Options
Working with flowchart files
Running Flowcode
Creating a new flowchart
Opening an existing flowchart
Saving a flowchart
Printing flowcharts
Saving Flowchart images
Closing Flowcode
Global options
Creating and editing flowcharts
Adding an icon to a flowchart
Selecting icons
Moving, deleting, copying and pasting icons
Undo and Redo
Supplementary code
Editing icon properties
Using masks
Input icon properties
Output icon properties
Delay icon properties
Decision icon properties
Switch icon properties
Connection point icon properties
Loop icon properties
Macro icon properties
Component Macro icon properties
Calculation icon properties
String manipulation icon properties
Interrupt icon properties
Code icon properties
Comment icon properties
Adding and editing components
Adding components
Editing component connections
Component help files
Component Properties
Panel Creator
Personalizing the Panel
Panel Properties
Text Properties
Image Properties
Shape Properties
Bevel Properties
Line Properties
Code customization
Customizing Component Macro Code
Customize Code Window
Edit Code Window
Working with macros and variables
Creating variables
Changing variable types
Parameters and Local variables
Creating a new macro
Editing and deleting macros
Exporting a macro
Importing a macro
PICmicro Custom Interrupts
AVR Custom Interrupts
ARM Custom Interrupts
String manipulation functions
Simulating a flowchart
Starting flowchart simulation
Simulating icons step by step
Changing the speed of a simulation
Pausing and stopping a simulation
Adding and using breakpoints
Watch window
Call stack window
In Circuit Debugging
Editing Key Mappings
Compiling flowcharts to Chips
Specifying a target Chip
Configuring the Chip
Compiling a flowchart to a Chip
Specifying compilation options PIC
Specifying compilation options AVR
Specifying compilation options ARM
Adding support for a third party programming tool
Viewing Code output
Virtual Networks
Vnet Server
Hosting a Vnet
Joining a Vnet
Exposing components to the Vnet
Vnet Connections Diagram
Simulating the Vnet
Developing a flowchart for a Chip
Flowcode allows you to create simple microcontroller applications by dragging and dropping icons on to a flowchart to create simple programs. These programs can control external devices attached to the microcontroller such as LED's, LCD displays etc.
Once the flowchart has been designed, its behavior can be simulated in Flowcode before the flowchart is compiled, assembled and transferred to a Chip.
To achieve this using Flowcode, perform the following steps:
1. Create a new flowchart, specifying the microcontroller that you wish to target.
2. Drag and drop icons from the toolbar onto the flowchart to program the application.
3. Add external devices by clicking on the buttons in the components toolbar, edit their properties, how they are connected to the microcontroller and call macros within the device.
4. Run the simulation to check that the application behaves as expected.
5. Transfer the application to the microcontroller by compiling the flowchart to C and then to object code.
Introduction
Welcome to Flowcode. Flowcode is a software program that allows you to create complex microcontroller programs for microcontroller Chips.
This help file contains the information you need to look at to help you use Flowcode to program Chips. If you feel we have left anything out, or if you have any technical questions, please visit our forums at:
(www.matrixmultimedia.com/mmforums/)
Additionally please visit our web site at: (www.matrixmultimedia.com) where you will find a list of Frequently Asked Questions as well as any patches or updates you may need.
How to use this help file
This help file should be used in conjunction with the example files provided to teach you how to use Flowcode. These are shipped with Flowcode and will be in the Examples subdirectory of the location where you installed Flowcode during the installation process. Work through each example and refer to the help file for further information on the actions taking place within each example as you go through them. If you do not understand immediately then move on and come back to a example later.
We suggest that you skim through this help file briefly so you know where to refer to for information later.
Context Sensitive Help
Within all Flowcode sub-windows you will find small buttons with a '?' on them. This will bring up context sensitive help on the appropriate functions.
Also at many times pressing the function key F1 will display context sensitive help for the item that is currently selected.
Presumed knowledge
Flowcode is targeted at users who are familiar with the following:
The basics of digital logic
What a Chip is
What a Chip does
That Chips need a clock input
That Chips have internal circuitry, such as timers, that can be used by programs
Flowcharts and their operation
Basic Windows™ skills such as copy, paste etc.
Simple electronic circuits such as LED's, switches, transistors used a switches etc.
If your knowledge is lacking in any area then don't panic! Just remember that you may not understand everything first time. You may benefit from using one of a wide range of electronics learning CD ROMs published by Matrix Multimedia - see our web site for details.
Using masks
Before looking at the operation of icons you will need to understand how 'masks' are used within Flowcode. You may wish to come back to this screen once you have looked at how Input and Output icons work.
Masks can be used to select specific number of bits on a port to read from, or write to. Masks can be used with Input icons and Output Icons.
Masks are particularly useful when the same port has both input pins and output pins as they facilitate the control/reading of two or more bits at the same time.
Using masks with Input icons
Bits selected in a mask allow their corresponding value to be sent to the variable. Non-selected bits return zero
Examples:
If all five switches on Port A were pressed with the above mask only the values for A1 and A2 would be passed to the variable SWITCHES giving it the value of 6, rather than the value 31 which the five switches add up to.
If switch A3 was pressed then the value zero would be passed to the variable SWITCHES as A3 is not selected.
Using masks with Output icons
Bits selected in a mask are passed the value of the corresponding bit of the number or variable sent.
Bits that are not selected are not affected and retain their prior value.
Examples:
If SWITCHES is equal to 255 and is sent with the mask above then bits B0, B1 and B2 will be affected. The other bits B3 - B7 will not be affected, and will retain whatever Bit value they have before the output message. Bits B0 - B2 will be set as the corresponding bits of SWITCHES are set.
If SWITCHES is equal to 32 then bits B0 to B2 will be cleared as the corresponding values for the B0 to B2 are all 0.
Bit B5, which corresponds to the value 32 is not affected as it is not selected.
Adding an icon to a flowchart
Icon toolbar
To add a new icon to a flowchart, click the mouse down on the icon you require, the cursor will change to a small image of that icon, drag the icon onto the active flowchart window and release the mouse button at the point where you want the icon inserted. As you move the mouse over a flowchart, a small arrow will appear indicating where the icon would be inserted when the mouse button is released. This is known as the insertion point.
Once you release the mouse button, the icon appears in the flowchart and the icon's name and details appear to the right of the icon.
Selecting icons
Before editing or moving an icon, it is necessary to select it. Selected icons appear in reverse on a black background. There are two ways to select one or more icons:
1. Click on a single icon to select it. To add to or subtract from the selection, hold down the Ctrl key whilst clicking on other icons.
2. Click and drag a selection rectangle around one or more icons that you wish to select.
Adding and using breakpoints
Adding and removing breakpoints
Breakpoints can be toggled on or off by selecting the icon at which point you wish to break and selecting Toggle Breakpoint from the Edit menu. Alternatively you can toggle the breakpoint with the F9 function key.
To clear all breakpoints select Clear All Breakpoints from the Edit menu.
Using breakpoints
When a flowchart is simulating it will stop at the first breakpoint that it reaches. Pressing Play again will resume program flow - to the next breakpoint if there are more than one.
When at a breakpoint the user can examine variable values, inputs and outputs etc.
Breakpoints are useful for stopping the program at the start of a problematic piece of code to allow the user to step through and debug the code.
If the ICD Mode is enabled in your project options then enabling a breakpoint will cause the ICD hardware to stop the target on a particular flowchart icon.
Configuring the Chip
The Chip can be configured from the Configure option from the Chip menu.
Please note that it is important to check the configuration before downloading to a Chip.
Please ensure that the Chip type and oscillator type are correct for your program as these are the main source of user problems.
Users with version 1 Matrix development boards need to set Version 1 compatible mode on the configuration page.
Configuring the chip for PICmicros with the default download program (PPP)
Clicking on the Configure menu item calls up the Configuration page.
Simple mode of PPP
Expert mode of PPP
The configuration page can be used to:
Specify the Chip being used
Set the oscillator type required
Enable/disable timers
Set which version of Matrix development board you are using (the options button at the bottom)
If you are using Flowcode for the very first time, or have changed development boards, you may need to check the options to set which board you are using.
Other options are also available (see the help file for details).
More information can be found in the help file, which can be accessed from the '?' help button in the lower left of the screen.
Manually configuring the chip for PICmicros for another download program
Click here for help with switching off the default configuration options that use PPP.
Once you have disabled the default configuration options you can enter your own configuration data. For the PICmicro this data will be sent to the chip every time you perform a compile to chip operation.
An example configuration word for the PIC16 series is
0x2007, 0x3FFC
The 0x2007 is the location in memory of the configuration word and the 0x3FFC is the configuration word itself.
An example set of configuration words for the PIC18 series is
0x300000, 0x00
0x300001, 0x22
0x300002, 0x0D
0x300003, 0x0E
0x300004, 0x00
0x300005, 0x00
0x300006, 0x80
0x300007, 0x00
0x300008, 0x0F
0x300009, 0xC0
0x30000A, 0x0F
0x30000B, 0xE0
0x30000C, 0x0F
0x30000D, 0x40
Configuring the Chip for AVRs
The Chip can be configured from the Configure option in the Chip menu.
Please note that it is important to check the configuration before downloading to a Chip.
Configuration settings for individual devices may be represented by 1, 2 or 3 bytes
The function of many of the individual configuration bits are also device dependent.
The data sheet for the relevant target device should be consulted before sending configuration data.
The default setting is configured to send the hex value 0xdf (223 decimal) to parameter location 0
The parameter locations are:
0 = Fuse High Byte (hfuse)
1 = Fuse Low byte (lfuse)
2 = Extended fuse Byte (efuse)
An example of 3 bytes of configuration data is shown below
OK and Send
Save the configuration data and send to the target device
OK
Confirm the configuration data but do not send to the target device
Note: Configuration memory might have a lower endurance than program memory. Only send configuration data when changes are required.
Selecting a target Chip
Introduction
Each version of Flowcode is capable of generating code for a number of target devices, each one having a different combination of properties and characteristics.
Before you use Flowcode to develop a Chip application you will need to choose one of these devices. Helping you make this selection is beyond the remit of this help file. Once you have made your choice of device you will need to make other choices concerning the Chip and your circuit - particularly concerning clock speed.
Before getting a program into your Chip you will need to take several steps to enter data about your Chip into several places:
1 Tell Flowcode which Chip you are using
2 Tell Flowcode what clock speed you are running at
3 Tell Flowcode what configuration settings you wish to use
Selecting device type from within Flowcode
You will be asked to select a Chip when you first select File….New. You can change devices at any time by selecting Edit....Project Options.
Use this option to specify which microcontroller you wish your flowchart to target. If you are changing from one microcontroller to another, Flowcode will check that all the commands and components in your flowchart are supported by the new microcontroller. Flowcode will advise you of any potential problems.
Selecting clock speed within Flowcode
Flowcode needs to know how fast you are clocking your Chip so that it can implement the delay function with the correct delay time. You can alter the Chip clock speed by selecting Edit....Project Options and entering the correct value of your clock circuit.
Selecting configuration options
Once you have chosen your Chip you will need to decide what type of oscillator you want to use. All Chips require an oscillator circuit which is used to clock the internal processor hardware. There are many options for oscillator types ranging from low speed resistor capacitor circuits through to high speed high accuracy crystal oscillators. As well as the oscillator type there are normally more settings for advances features such as watchdog timers and brown out detection. The chip configuration settings can be accessed by using the Chip....Configuration menu.
Microcontrollers
PICmicro datasheets are available from www.microchip.com.
ARM and AVR datasheets are available from www.atmel.com
Component help files
Help files for individual components can be accessed via the properties screen. The help button on the dialog accesses the help file for that particular component rather than the main Flowcode help file.
This allows additional components to be added at a later date, or from third parties, and have a help file which is accessible from Flowcode.
The help file will detail connections and operating details for the component.
Help files for the standard components have also been added to this main help file to aid the user.
Adding components
To add a component to the flowchart, simply click on the appropriate button in the Components Toolbar. Flowcode will then add an instance of the component to the simulation panel window.
To remove the component or edit the connections and properties of the component click on the component in the panel and the options will appear in the properties tab.
If the properties tab is not visible then you can open it by right clicking a component on the panel and selecting properties.
Delete
Deletes the component.
Note that Flowcode will not allow you to delete a component that is called from macros in your flowchart. Remove the macros before deleting the component.
Component Connections...
Selecting this option allows you to configure the components connections.
See the Editing component connections page for more details.
Properties...
Certain components can be configured using additional properties that they possess. To edit a component's properties select Properties from the drop down menu. A dialog for the component's properties will then appear. If the component does not have any additional properties then a blank properties page will be shown.
See individual component help pages for details on any properties that they may have.
Note that if you are loading a tutorial it may have some components attached that are not shown on the simulation. Select View…Attached components and then select any components to see the simulation windows.
No help available
No help is available for this message box.
Technical support
User forums
There are a number of User forums on the matrix Web site, including a Flowcode forum, as well as other Chip related forums.
Users are advised to visit the forums for both technical support questions and general information and advice.
The forums can also be used for general chats about Flowcode and or programming in general etc.
Technical support
Technical support for Flowcode can be found on the Matrix Multimedia web site at: http://www.matrixmultimedia.com.
The web site contains Frequently Asked Questions, Technical support information and any updates available for Flowcode.
In addition support can be obtained via email: support@matrixmultimedia.co.uk.
Please check the web site and the forums before emailing as solutions to many simple problems can be found there.
NOTE: Technical support is for installation and product support issues. It is NOT for coding problems or for general advice and information.
If you need help with coding, such as how to manipulate some strings, or general advice, such as suitable chips for a project, please use the Matrix forums.
Known issues
Compiling with Limited or Restricted user accounts
If you are using Flowcode with a Limited or Restricted user account you will need
to contact the Network Administrator to have read/write privileges set up for
the registry key HKEY_LOCAL_MACHINE\Software\Licenses.
This issue affects Windows 2000 and Windows XP users.
Files on MRU List sometimes don't work.
When you open Flowcode and select a file from either the list in the Welcome dialog,
or from the list of files at the end of the FILE menu,
the program may sometimes fail to compile correctly.
To get around this open the file from the FILE -> OPEN menu items.
This problem seems to affect Restricted/Limited User accounts in particular.
Flowcode's tools and views
The Flowcode environment consists of a main work area in which the flowchart windows are displayed, several toolbars that allow icon and components to be added to the flowchart application, three windows that allow the status of the microcontroller and attached components to be viewed and two windows that display variables and macro calls when the flow chart is being simulated.
Icons Toolbar
Drag and drop icons from this toolbar onto the main flowchart window to create your flowchart application.
Components Toolbar
This toolbar displays the external components that can be connected to a microcontroller. Click on a component and it will be added to the microcontroller in the Microcontroller view. The pin connections and properties of the component can then be edited.
Docking and Undocking the toolbars
The toolbars can be undocked from the default position and either left free floating, or can be docked to the menu bar, the sides or the bottom of the Flowcode window.
To undock a toolbar simply click and hold on the toolbar grab bars if docked, or the caption bar if undocked and drag the toolbar to its new position.
Microcontroller View
The current microcontroller is displayed in this window along with any external components attached to the microcontroller. When the flowchart is being simulated, the state of the microcontroller I/O ports are shown on the microcontroller as red and blue for high and low outputs respectively.
Flowchart Window
The icons that make up the flowchart are displayed in this window. In addition, the icons that make up a macro are shown in their own separate window. The Main flowchart window is always visible and the macro windows can be shown and hidden as needed.
External Component View
The status of one of the components attached to the microcontroller is displayed in this view. The component becomes 'active' when simulating the flowchart. The view also allows you to interact with external components for example, closing and opening switches.
Variables View
When simulating a flowchart, the values of any variables used can be seen in this view. The values of the variables are updated for every command simulated but the view is not updated when the simulation is running at full speed.
Call Stack View
This shows the current macro being simulated. This is useful when one macro calls another during the simulation process.
Toolbar
Use this command to display and hide the Toolbar, which includes buttons for some of the most common commands in Flowcode, such as File Open. There are also buttons for starting, stopping and pausing the simulation on the toolbar.
Status Bar
Use this command to display and hide the Status Bar, which describes the action to be executed by the selected menu item or depressed toolbar button, and keyboard latch state. A check mark appears next to the menu item when the Status Bar is displayed.
Current Zoom level
The currently selected Zoom level is displayed on the right side of the Status bar.
Starting flowchart simulation
To simulate a flowchart, select the Go/Continue option from the Run menu or press F5. Flowcode will go into simulation mode and will start to execute the icons in the flowchart. A red rectangle indicates the icon that is about to being executed. The variables, call stack and Chip windows are updated on every step of the simulation. In addition, if there are external components attached to the microcontroller then their state is shown in the external component window.
If you have asked Flowcode to simulate the flowchart as fast as possible then the variables, call stack and microcontroller views are not updated until you pause the flowchart execution.
Alternatively if you wish to simulate the flowchart step by step from the start, then use the Step option from the Run menu or press F8.
See Changing the speed of a simulation to alter the simulation speed
If the ICD Mode is enabled in your project options then starting the simulation will cause the ICD hardware to begin running.
Some of the components do not have a simulation feature. These components have a red box drawn around them when they are displayed on the panel. The red box indicated that the component will dissapear when the simulation is running.
Pausing and stopping a simulation
Simulations can be paused or finished by selecting either the Pause or Stop options from the Run menu.
If the flowchart is being simulated as fast as possible then Flowcode will update the variables, call stack and microcontroller views when the simulation is paused. A red rectangle will appear around the next icon that is due to be simulated.
Changing variables during Simulation
When simulating variable values can be changed from the Variables watch window by double clicking on the variable name.
A Change variable value dialog will appear allowing you to edit the variable value.
Simulating icons step by step
Step Into
To simulate the flowchart, icon by icon, select the Step Into option from the Run menu or press the F8 key. A red rectangle indicates the icon that is about to being executed. The variables, call stack and Chip windows are updated on every step of the simulation. In addition, if there are external components attached to the microcontroller then their state is shown in the external component window.
Step Over
To Step Over a macro select the Step Over option from the Run menu or press the Shift + F8 keys. Step Over works in the same way as Step Into, but with the following difference. When Step Over encounters a macro that contains a separate flowchart Step Over processes the whole macro instead of opening it and executing it step by step. In effect it steps over the flowchart.
Step Over is useful to avoid having to step through lengthy macros and allows the user to concentrate on other areas of the flowchart that may require their attention.
Changing variables during Simulation
When simulating variable values can be changed from the Variables watch window by double clicking on the variable name.
A Change variable value dialog will appear allowing you to edit the variable value.
If the ICD Mode is enabled in your project options then stepping into or over in the simulation will cause the ICD hardware to react accordingly. Changing variable values during the simulation will also work seamlessly with the ICD operation.
Compiling a flowchart to a Chip
Introduction
Chips can only execute code that is in hexadecimal (hex.) format. Flowcode needs to process your flowcharts (for example TEST.FCF) into a format that a Chip can execute Flowcode takes a number of steps:
1 Compile Flowchart into C code
2 Compile C code into Assembler
3 Assemble the Assembler into Hex
4 Send the Hex code to the Chip
Whilst this seems a bit long-winded it has the advantage that it allows you to embed third party C code or Assembly code into your programs without actually getting too bogged down in creating the code - or understanding it.
The various options available allow users to halt the process at various stages so that they can view the resulting code, or check for errors at that code level.
Before compiling your flowchart into a program that can be sent to a Chip you will need to ensure you have followed the instructions in the section entitled Selecting a target Chip.
Compile to C
Compiles the Flowchart to C code.
The resulting C file is saved in the program directory, with a .c extension, and can be viewed or used by external programs.
Select the Compile to C option from the Chip menu.
Flowcharts must be saved before they can be transferred and Flowcode will prompt you if this is the case.
You can also use the Compile to C icon on the toolbar.
Compile to Hex
Compiles the Flowchart to C code and then compiles the C code to Assembly and Machine code.
The resulting ASM file is saved in the program directory, with a .asm extension, and can be viewed or used by external programs.
The resulting machine code file is also saved in the program directory with a .hex or .bin extension.
Select the Compile to ASM option from the Chip menu.
Flowcharts must be saved before they can be transferred and Flowcode will prompt you if this is the case.
You can also use the Compile to Chip icon on the toolbar.
Compiling to Chip
Unlike the pervious two methods Compile to Chip actually programs the Chip after compiling the machine code file.
Compile to Chip compiles the Flowchart to C code, then ASM code, then assembles the ASM to Machine code and launches the Programmer application to download the program into the Chip.
Select the Compile to Chip option from the Chip menu to transfer the flowchart to the target microcontroller.
Flowcharts must be saved before they can be transferred and Flowcode will prompt you if this is the case.
You can also use the Compile to Chip icon on the toolbar.
Please check your Configuration information before downloading, or if you are having problems: Many perceived errors are as a result of the incorrect set up.
Compiling with non standard applications
Flowcode is optimized for use with the Boost C compiler and linker and the C code may not be appropriate for other compilers.
Exporting a macro
Macros you create can be exported to a file for later use. Select the Export option from the Macro menu. Flowcode will first ask you to select the macro you wish to export and then ask you for a filename. Flowcode macros are exported with the file extension .FCM
If the Read Only tick box is ticked then the exported macro will be locked making the macro uneditable when importing back into other Flowcode programs.
Importing a macro
To import a previously exported macro into Flowcode, select Import from the Macro menu. Flowcode will ask you to choose the filename of the existing macro. Flowcode will then import the macro using the same macro name as when it was exported. If the macro name already exists then Flowcode will ask for a new name for the macro.
Any variables used in the macro will be added to those already in the main program allowing you to use those variables in other parts of your program.
If any of the variables names already exist then a warning message will appear asking if you wish to proceed with the import.
If you proceed you will be asked if you wish rename the conflicting variables.
Rename macro variable changes the macro name to the one in the text edit box.
Use existing variable treats the imported variable as being references to the already existing variable, keeping the same name.
Editing icon properties
The properties of an icon define how it behaves when compiled/assembled and when simulated in Flowcode. As each icon has different properties that the user can edit: see the topic on the particular icon of interest.
To edit an icon's properties, either select the icon and the select the Properties option from the Edit menu or simply double click on the icon in the flowchart. The icon's properties can also be displayed by right clicking on the icon to display a context menu and then selecting properties from that menu.
Input icon properties
Output icon properties
Delay icon properties
Decision icon properties
Connection point icon properties
Loop icon properties
Macro icon properties
Component Macro icon properties
Calculation icon properties
Interrupt icon properties
C code icon properties
String manipulation icon properties
Comment icon properties
Attached components
The list of components attached to your program is available by clicking on the drop down menu on the properties menu.
If the properties menu is hidden then you can reopen it by right clicking in the panel window and selecting properties.
To edit a particular components properties simply select the component in the panel or choose the component from the drop down list.
Analogue inputs
Available from the View menu when simulating a flowchart with analogue input components.
Gives a graphically readout of the analogue inputs to the microcontroller.
Requires a microcontroller with analogue inputs.
Zooming the view
Set the program zoom size.
The current zoom setting is displayed on the Zoom sub menu, and on the right hand side of the status bar
Settings include
25% - set size zoom
50% - set size zoom
75% (F4) - set size zoom (Default zoom)
100% - set size zoom
Increase Zoom (F3) - increases zoom size by 5%
Decrease zoom F2 - decreases zoom size by 5%
Zoom to fit - Zooms to fit the whole flowchart into the current window.
Zoom to fit width - Zooms to fit the width of the flowchart into the width of the window.
Current zoom - Displays current zoom size in percent.
Holding down the control key while scrolling the mouse wheel will also adjust the current zoom setting.
Creating a new flowchart
Create a new flowchart by selecting New from the File menu. Select the microcontroller that you wish to target from the list presented. Flowcode will then display the microcontroller in the Microcontroller View and create an empty flowchart for you to start adding your icons to.
Saving a flowchart
To save a flowchart, select either the Save or Save As options from the File Menu. Flowcharts must be saved before they can be compiled to C or transferred to a microcontroller.
Opening an existing flowchart
There are several ways of opening an existing Flowcode flowchart.
1. Select the Open option from the File menu. This will allow you to browse for the file you want.
2. Select the file from the list of most recently used files in the File menu.
3. Double click on a flowchart file in Windows Explorer to launch Flowcode an open the file.
Closing Flowcode
To close a Flowcode flowchart, select Close from the File menu. To close the entire Flowcode application, select Exit from the File menu. In both cases, Flowcode will ask you if you wish to save the changes to any modified flowcharts.
Printing flowcharts
Use the Print preview command to display the flowchart as it would appear when printed. When you choose this command, the main window will be replaced with a print preview window in which one or two pages will be displayed in their printed format. The print preview toolbar offers you options to view either one or two pages at a time; move back and forth through the document; zoom in and out of pages; and initiate a print job.
Alternatively, the print job can be initiated without preview by selecting Print from the file menu.
Moving, deleting, copying and pasting icons
Icons can be moved, deleted, copied to the clipboard and pasted from the clipboard.
To move one or more icons from one position to a new position within the same flowchart:
Select the icons and then click and drag the icons to their new desired insertion point. As you drag the icons, the insertion point marker will indicate where the icons will be inserted when the mouse is released. Note that it is not possible to insert icons at a point within the icons themselves.
To delete icons from a flowchart:
Select the icons and then either select Delete or Cut from the Edit menu to remove the icons from the flowchart. If Cut is used then the icons are placed on the clipboard and can be subsequently pasted into this or another flowchart.
To copy icons from a flowchart:
Select the icons and then select Copy from the Edit menu to place a copy of the icons on the clipboard. These icons can be subsequently pasted into this or another flowchart.
To paste icons from the clipboard into a flowchart:
Choose the insertion point of the icons by clicking on the flowchart and then select Paste from the Edit menu.
The delete, cut, copy and paste options are also available from the context menu that appears when right clicking on an icon.
Vnet Server
Flowcode is now capable of talking to other instances of Flowcode either running on a single PC or running over a network. This allows for bus based components such as RS232 or CAN to simulate and interact with multiple Flowcode programs like the hardware would do in real life. Before the virtual network or Vnet can be used a small application called the Vnet server must be running on your PC or at least somewhere on your network.
The Vnet Server is responsible for collecting and relaying all the Vnet messages between instances of Flowcode. Start up the server by running the FlowServer link located in the Flowcode start menu folder. Multiple distinct Vnets can be run using a single server.
Once the server is running it will appear as an small icon in your taskbar.
Right clicking the icon allows the Vnet Server control menu to appear.
Start
Starts the Vnet server running allowing Vnet operations to take place.
Stop
Stops the Vnet server stopping all activity on the Vnet.
Properties
Brings up the properties window for the Vnet server.
Server Port
Configures the communications port for the Vnet communications.
By default this is set to 8117.
Server Address
Configures the communications IP for the Vnet communications.
By default this is set to use the IP of your network interface.
About
Vnet server version information.
The Vnet server software also features a debug mode that can be used to monitor communications and activity on the Vnets. To startup the Vnet server in debug mode run the FlowServer Debug link in the Flowcode start menu folder.
Contents
Contents:
Introduction
Getting Started
Working with flowchart files
Creating and editing flowcharts
Adding and editing components
Working with macros and variables
Simulating a flowchart
Compiling flowcharts to Chips
Virtual Networks
Introduction
Introduction
New In Version 4
Chips
Technical Support
Getting Started
Developing a flowchart for a Chip
Flowcode's tools and views
Zooming the view
Selecting a target chip
Project Options
Working with flowchart files
Running Flowcode
Creating a new flowchart
Opening an existing flowchart
Saving a flowchart
Printing flowcharts
Saving Flowchart images
Closing Flowcode
Global options
Creating and editing flowcharts
Adding an icon to a flowchart
Selecting icons
Moving, deleting, copying and pasting icons
Undo and Redo
Supplementary code
Editing icon properties
Using masks
Input icon properties
Output icon properties
Delay icon properties
Decision icon properties
Switch icon properties
Connection point icon properties
Loop icon properties
Macro icon properties
Component Macro icon properties
Calculation icon properties
String manipulation icon properties
Interrupt icon properties
Code icon properties
Comment icon properties
Adding and editing components
Adding components
Editing component connections
Component help files
Component Properties
Panel Creator
Personalizing the Panel
Panel Properties
Text Properties
Image Properties
Shape Properties
Bevel Properties
Line Properties
Code customization
Customizing Component Macro Code
Customize Code Window
Edit Code Window
Working with macros and variables
Creating variables
Changing variable types
Parameters and Local variables
Creating a new macro
Editing and deleting macros
Exporting a macro
Importing a macro
PICmicro Custom Interrupts
AVR Custom Interrupts
ARM Custom Interrupts
String manipulation functions
Simulating a flowchart
Starting flowchart simulation
Simulating icons step by step
Changing the speed of a simulation
Pausing and stopping a simulation
Adding and using breakpoints
Watch window
Call stack window
In Circuit Debugging
Editing Key Mappings
Compiling flowcharts to Chips
Specifying a target Chip
Configuring the Chip
Compiling a flowchart to a Chip
Specifying compilation options PIC
Specifying compilation options AVR
Specifying compilation options ARM
Adding support for a third party programming tool
Viewing Code output
Virtual Networks
Vnet Server
Hosting a Vnet
Joining a Vnet
Exposing components to the Vnet
Vnet Connections Diagram
Simulating the Vnet
Running Flowcode
When the Flowcode application starts, you have the option of loading an existing Flowcode file or creating a brand new flow chart.
Flowcode keeps a list of the four most recently used files and these can be selected and opened by a double click. Select the 'More files' option if the file you want to open is not on the recently used list.
Code icon properties
Flowcode is designed to allow those new to Chip 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.
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 all Flowcode macro names are upper case.
To jump to a connection point called A, defined in a Flowcode macro called TEST, you C code must be goto FCC_TEST_A;. Connection points defined in the main flowchart of a Flowcode file are prefixed FCC_Main_.
To enter a tab character in the C code field, use Ctrl+Tab
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:
asm
{
; Enter your code here
}
To 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.
Decision icon properties
Decision icons allow you to test a condition and redirect the flow according to the outcome.
Icons can be placed in either branch from the decision icon.
Display Name
The name of the icon that appears on the flowchart.
Condition
The decision box tests this condition to see which branch to continue down. If the condition evaluates to 0 or false then the 'No' branch is chosen. If the condition evaluates to a non zero number or true then the 'Yes' branch is chosen. Conditions can be made up from numbers, variables and the following operators:
(, ) - Parentheses.
=, <> -Equal to, Not equal to.
+, -, *, /, MOD - Addition, Subtraction, Multiplication, Division & Modulus.
<, <=, >, >= - Less than, Less than or equal to, Greater than, Greater than or equal to.
>>, << - Shift right, Shift left.
NOT, AND, OR, XOR - NOT, AND, OR, Exclusive OR
Numeric values can be in decimal (unmarked) or in HEX format (preceded by 0x) or in Binary format (preceded by 0b) e.g. 255 or 0xFF or 0b01010101.
Assuming that the variables have been previously defined, all the following are valid if statements.
DELAY = 10
DELAY = MAXDELAY
NEXTBIT = LASTBIT >> 2 & MASK
AANDB = PORT_A AND PORT_B
INVX = NOT X
Variables button
This button brings up the variables dialog window allowing you to select an existing variable or to create a new one.
Swap Yes and No
Normally the 'Yes' path of execution goes off to the right of the decision icon and the 'No' path carries on down the flowchart. Select this option to swap the two branches around.
Boolean values
Flowcode treats zero as false and any non-zero value as true.
This allows the use of variables in a true or false context.
For example 'If TIMEUP' would execute the 'Yes' path if TIMEUP was non-zero.
Calculation icon properties
Calculation icons allow the modification of variables. They can be used to check inputs and to create outputs.
Display Name
The name of the icon that appears on the flowchart.
Calculations
One or more lines of calculations can be entered into this box
All calculations must consist of the name of an existing variable, and equals sign and an expression made up from numbers, variables and the following operators:
( ) - Parentheses.
= <> -Equal to, Not equal to.
+ - * / MOD - Addition, Subtraction, Multiplication, Division & Modulus.
< <= > >= - Less than, Less than or equal to, Greater than, Greater than or equal to.
>> << - Shift right, Shift left.
NOT AND OR XOR - NOT(inversion), AND, OR, Exclusive OR
Numeric values can be in decimal (unmarked) or in HEX format (preceded by 0x) or in Binary format (preceded by 0b) e.g. 85 or 0x55 or 0b01010101.
Assuming that the variables have been previously defined, all the following are valid calculation lines.
DELAY = DELAY + 1
DELAY = (MYVAR + 3) * 3
NEXTBIT = LASTBIT >> 2 & MASK
AANDB = PORT_A AND PORT_B
INVX = NOT X
Browse for variable button
This button brings up the variables dialog window allowing you to select an existing variable or to create a new one.
See the Creating variables page for more information on variables.
Functions (Flowcode PIC only)
Flowcode includes an additional set of mathematical functions:
float = fadd(float, float) - Add two floating point numbers together
float = fsub(float, float) - Subtract two floating point numbers
float = fmul(float, float) - Multiply two floating point numbers
float = fdiv(float, float) - Divide two floating point numbers
float = fmod(float, float) - MOD function for floating point numbers
byte = isinf(float) - Checks to see if the floating point number is infinite
byte = isnan(float) - Checks to see if the floating point is not a number
byte = float_eq(float, float) - Compares two floating point numbers to see if they are equal
byte = float_ge(float, float) - Compares two floating point numbers to see if they are greater then or equal
byte = float_gt(float, float) - Compares two floating point numbers to see if they are greater then
byte = float_le(float, float) - Compares two floating point numbers to see if they are less then or equal
byte = float_lt(float, float) - Compares two floating point numbers to see if they are less then
int = random() - Generates a random number -32768 <=> 32767
Functions (Flowcode AVR only)
Flowcode includes an additional set of mathematical functions:
fabs( x ), floor( x ), ceil( x ) - absolute value, floor and ceiling functions
fmod( x , y ) - floating point modulus (remainder of x divided by y)
sqrt( x ), cbrt( x ) - square and cube roots
log( x ), log10( x ) - logarithms (base e and base 10)
exp( x ), pow( x , y ) - exponential and power functions (x to the power of y)
sin( x ), cos( x ), tan( x ) - trigonometric functions
asin( x ), acos( x ), atan( x ), - inverse trigonometric functions
atan2( y , x ) - four-quadrant inverse tangent
sinh( x ), cosh( x ), tanh( x ) - hyperbolic functions
isnan( x ), isinf( x ) - tests for not-a-number and infinity
Functions (Flowcode ARM only)
Flowcode includes an additional set of mathematical functions:
fabs( x ), floor( x ), ceil( x ) - absolute value, floor and ceiling functions
round( x ) - decimal rounding (x rounded to the nearest integer)
fround( x , y ) - floating point rounding (x rounded to y decimal places)
fmod( x , y ) - floating point modulus (remainder of x divided by y)
sqrt( x ), cbrt( x ) - square and cube roots
log( x ), log10( x ) - logarithms (base e and base 10)
exp( x ), pow( x , y ) - exponential and power functions (x to the power of y)
sin( x ), cos( x ), tan( x ) - trigonometric functions
asin( x ), acos( x ), atan( x ), - inverse trigonometric functions
atan2( y , x ) - four-quadrant inverse tangent
sinh( x ), cosh( x ), tanh( x ) - hyperbolic functions
asinh( x ), acosh( x ), atanh( x ) - inverse hyperbolic functions
fact( x ) - factorial
random( ) - random number between 0 and 32767
isnan( x ), isinf( x ) - tests for not-a-number and infinity
Delay icon properties
Delay icons are used to slow down program execution and for program timing.
They are particularly useful in slowing program execution speed down to allow for human interaction.
Display Name
The name of the icon that appears on the flowchart.
Delay value or variable
This is the length of the delay that you wish to create.
Variables button
This button brings up the variables dialog window allowing you to select an existing variable or to create a new one.
Microseconds/Milliseconds/Seconds options
Delays can be specified in units of microseconds, milliseconds or seconds. When simulating delays in seconds, a dialog box will appear showing how much of the delay has elapsed. A cancel button on the dialog allows the execution of the flowchart to continue before the entire delay has passed.
To allow Flowcode to correctly program your Chip with the correct delay setting you will need to select a clock speed for your Chip. The dialog box for this can be seen by selecting Edit....Project Options.
Interrupt icon properties
Introduction to Interrupts
Interrupts are called to react to an event such as an external stimulus, or a timing event.
When an interrupt is activated it executes a Macro. The macro to be called is specified by the user when creating the interrupt.
The number and types of interrupts available are dependent on the device used. Some devices have a number of interrupts whereas other devices may only have a few.
The exact details, properties and operation of an interrupt vary from interrupt to interrupt. Users will need to refer to the interrupt dialogs for exact details of any particular Interrupt. However there are four main types that Flowcode uses:
• TMR<X>- overflow - reacts to the clocked overflow event
• INT - reacts to an input on an external interrupt pin.
• Port change -reacts to any change in a specified collection of inputs
• Custom - defines a custom interrupt procedure.
Details of the various interrupts can be found below, along with example of available properties.
Creating an interrupt
Add an Interrupt icon to the program.
Select Enable Interrupt or Disable Interrupt to turn the interrupt on or off respectively.
Select the desired interrupt from the drop down list of interrupts available from that particular device.
Set the properties for that event.
Set the macro to call, or create a new macro.
Interrupt properties
TMR<X> Timer overflow Interrupt (e.g. TMR0 overflow)
Interrupts when the Timer overflows. A count is made internally based on Clock inputs and the pre-scaler property (see below for details). When the count reaches a certain point it overflows back to 0 triggering an Overflow event. This event can then be used to call a macro. Timer overflow interrupts are called repeatedly at the Interrupt time interval making them very useful for time based events, or for frequently needed features such as display updates.
Note: Check that the clock speed setting is correct (via the Chip -> Clock Speed menu items) as clock speed affects timer interrupt frequency settings.
The exact properties available for a timer interrupt are device and timer dependent. As such the timer overflow dialogs may vary from device to device and from timer to timer. The example below is intended to give an idea of the kind of properties available for a Timer overflow interrupt.
Specific details can be found in the Interrupt dialogs, and from Device datasheets.
TMR1 on the 16F877A, for instance, has a smaller set of pre-scaler options than the TMR0 interrupt, and also no source edge settings available unlike the TMR0 interrupt.
The TMR2 interrupt has an additional setting called the rollover value. This changes the rollover value in the timer register that is responsible for triggering the interrupt which allows for much better control over interrupt frequency. This advanced timeout functionality can be replicated with the other timers by writing to the timer count registers directly using C code.
Note: Certain Flowcode components such as the PWM and Servo consume some of the timer peripherals. For details on the hardware consumed by a component please refer to the specific component help file.
Example of TMR0 properties:
Clock source select
Select the clock source signal to use for the overflow timing.
Options available are device dependent.
Examples:
• Internal clock (CLK0)
• Transition on T0CKI
Source edge select
Select the transition edge used for clock signal timing.
• High-to-low transition on T0CKI
• Low-to-high transition on T0CKI
Prescaler rate
Select a pre-scaler rate for the clock signal.
A prescaler divides down the clock signals used for the timer giving reduced overflow rates.
The rate can be set to a number of possible values. The exact values are chip dependent.
E.g. for the PIC16F877A values area a number of values are available ranging from 1:1 to 1:256.
The prescaler value is used in conjunction with the clock speed to set an overflow frequency.
E.g.
• Clock speed:- 19660800
• Prescale value:- 1:256
• Interrupt frequency 75Hz
• Clock speed:- 19660800
• Prescale value:- 1:64
• Interrupt frequency 300Hz
INT
Triggered when an external stimulus is used on an external interrupt (INT) pin (e.g. a Button press)
The interrupt can be set to trigger on the:
Falling edge of INT
Rising edge of INT
INT interrupts can be useful in setting interrupts to occur on signal on or signal off events, such as an emergency shut off switch.
Port change
Interrupts when an input signal occurs on any of a selected group of port inputs.
The Port change interrupt may have properties allowing the interrupt I/O pins to be enabled or disabled as interrupt pins.
Custom
The Custom option allows the creation of custom interrupt code.
Many of the chips available in Flowcode support hardware driven interrupts that are not provided in the standard set of Flowcode interrupts. To allow users to add their own interrupts to suit their application Flowcode has the option to add your own custom interrupt.
Interrupt Property page
Custom Interrupt property page
Click here for help using the PICmicro custom interrupts.
Click here for help using the AVR custom interrupts.
Click here for help using the ARM custom interrupts.
Macro icon properties
Macros have now been split into Macros and Component macros.
Component macros are pre-defined macros supplied with the components. For example LCD macros are used to display numbers and characters on the LCD display.
Component macros are only available for use with that particular component.
Component macros have hatched outer bands on the icon.
Macros (explained here) are those designed and created by the user.
Macros can be exported and imported allowing users to build up macro libraries of common or important tasks.
On Macros the outer bands are clear and not hatched.
Macros
Macros are sections of code, that can be used and reused in projects.
Macros allow complex tasks to be handled by code blocks and they can be imported and exported.
The macro properties dialog allows users to select and create macros.
Adding a Macro
Select the Macro to use from the list, or click on Create new macro to begin creating a new macro to add to the list.
Add in any parameters required, and select a return value if required.
Clicking on the OK button completes the process and closes the dialog.
Clicking on the OK and edit button completes the process, closes the dialog and opens the selected macro for editing.
Parameters
If the device macro requires any parameters then these can be entered in this field. They can be numeric values or existing variables. Each variable or value must be separated by a comma.
The parameter details will list the parameter type. Parameters must be of the required type to be accepted.
Note that a full set of parameters must be provided.
Variables button
This button brings up the variables dialog window allowing you to select an existing variable or to create a new one.
Return value
If the device macro returns a value then you can assign that value to an existing variable for use later in the flowchart. If the function returns a value but you do not wish to retrieve it then leave this field empty.
The variable type of the return value will be listed. A variable of the specified type must be used to accept the return value.
Create New Macro button
Select this button to create a new macro within the flowchart.
OK & Edit Macro button
Clicking this button will open up the chosen macro to allow it to be viewed or edited.
Creating new macros
Clicking the Create new macro button brings up the new macro dialog.
See Creating new macros for more information
Specifying a target Chip
Use this option to specify which microcontroller you wish your flowchart to target. If you are changing from one microcontroller to another, Flowcode will check that all the commands in your flowchart are supported by the new microcontroller. Flowcode will advise you of any potential problems. Similarly Flowcode will check that any external components connected to a microcontroller can be connected to the same pins on the new microcontroller. If any pins cannot be re-connected, Flowcode will advise you to change the connection before changing to the new microcontroller.
Creating variables
Viewing variables
Select the Variables option from the Edit menu to see a list of variables that have been defined in a flowchart. New variables can be defined using the Add New Variable button.
Variables can be deleted provided that they are not used by any icons within a flowchart. Flowcode will warn of this condition.
Creating variables
Enter the variable name including any array size details.
Variables can be a maximum of 32 alphanumeric characters. They can contain underscore ( _ ) characters but not spaces. At least one letter must be included in the variable name to distinguish it from a pure number.
Select the variable type for the new variable.
Note that variable names "retain" their capitalization, but Flowcode itself it not case sensitive. If a variable is created as "MyVar", then it will be shown as "MyVar" throughout the document. Note that the variable name is changed to "FCV_MYVAR" in the actual C code, as c code is case sensitive.
Variable types
Variables can be specified as one of the following types:
Type Range Bit Depth
BYTE 0-255 8-bit unsigned variable
INT -32768 to 32767 16-bit signed variable
String 0-255 8-bit unsigned array. Default size is 20.
Floating point -Inf to +Inf 32-bit signed variable
Numeric values can be in decimal (unmarked) or in HEX format (preceded by 0x) or in Binary format (preceded by 0b)
e.g. 255 or 0xFF or 0b11111111.
Strings are an array of ASCII characters.
An ASCII character is a BYTE variable corresponding to the ASCII value of the appropriate character.
If no array size is specified the default size of [20] characters is automatically assigned.
Arrays
Arrays can be created by adding an array size attribute in square braces to the variable name. E.g. MY_ARRAY[10] creates an array called MY_ARRAY with 10 members in the array.
You can set the value of an array member in a calculation icon by using the array name with the member number in square braces. E.g.MY_ARRAY[3] = 32.
Note that Arrays start at 0 i.e. an Array with 10 members will use 0-9 as the member numbers.
You can modify the array size by selecting the array in the list and clicking on the Array size button.
You can only edit the size attribute not rename the variable.
The only difference between an array of bytes and a string is that the string variable is available for use with the Flowcode string manipulation functions. In C code the two are identical.
Changing the speed of a simulation
Clock speed
Select the Clock Speed option from the Edit -> Project Options menu to change the speed of the simulation. Simulation speeds can vary from 0.25 Hz (or one simulation every 4 seconds) to 1000Hz (or one simulation every 0.001 seconds).
Simulation speed
In addition, you can ask Flowcode to simulate the flowchart as fast as possible. When this happens, Flowcode does not update the variables, call stack and microcontroller views whilst it is running but any external component views do get updated.
Configuration information
Select Configure from the Chip menu to open the Chip download configuration window.
A number of options are available that allow you to change download parameters. For details on the various options see Configuring the Chip.
Users with Version 1 development boards
Users with version 1 of the Matrix Multimedia development board may need to check that the Version 1 compatible box is checked on the PPP Configuration information page.
Selecting Compiler Options (PICmicro)
Allows users to set the Compiler options.
Substitute variables used by Flowcode
%t Target name e.g. 16F88
%f Filename without extension e.g. C:\Dev\Test\Mytest.fcf becomes - C:\Dev\Test\Mytest
%d Directory location of the Flowcode file
Compiler location
Sets the Compiler location.
Default:
C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\boostc.pic16.flowcode.exe
Compiler parameters
Adds command line parameters when called from Flowcode
Default:
-v -t PIC%p "%f.c"
Linker/Assembler location
Sets the Assembler program location.
Default:
C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\boostlink.pic.exe
Linker/Assembler parameters
Adds command line parameters when called from Flowcode
Default:
-ld "C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\lib" libc.pic16.lib "%f.obj" -t PIC%p -d "%d" -p "%f"
Programmer location
Sets the Programmer application location.
Default:
C:\Program Files\Matrix Multimedia\Common\PPPv3\PPPv3.exe
To use the PICkit2 programmer change the location to
C:\Program Files\Matrix Multimedia\Flowcode V3\tools\PICkit2\pk2cmd_mtx.exe
Programmer parameters
Adds command line parameters for the Programmer application.
Default:
-cs 2 -nogui "%f.hex"
To use the PICkit2 programmer change the parameters to
-PPIC%p -F%F.hex -M -A5 -H
Use Programmer to set configuration options
Check box to allow the Programmer application (PPP) to be used to set up the configuration of the device. Used by the Chip > Configure menu command to launch the application (PPP) to configure the device. This setting needs to be unticked to allow you to use non default programming applications such as the PicKit2.
Configuration parameters
Supplies the command line parameters needed for configuration.
Default:
-cs 2 -chip PIC%p -config
Note: The above Programmer defaults assume that you are using the PPP Programming application from Matrix Multimedia.
If you are using an alternative programming application you will need to consult the documentation for that application for the required parameters and settings.
Additionally configuration words can be embedded into the program using the Supplementary code feature, or C Code icons.
For help using the PicKit2 Programmer with Flowcode, untick the "Use Programmer to set configuration options" button and then click here to view the configuration settings required.
File Viewer location
Sets the File viewer location for viewing C and Assembly files.
Set to Windows Notepad by default.
Default:
C:\WINDOWS\notepad.exe
File Viewer parameters
Adds command line parameters for the File viewer program
Default:
Blank. NO PARAMETERS.
Selecting Compiler Options (AVR)
Substitute variables used by Flowcode
%T Target name as written e.g. atmega32
(generally used by the compiler)
%t Target name forced to lower-case
%p Target name forced to upper-case
%a Alternative target name as written e.g. m32
(generally used by the programmer)
%A Alternative target name forced to upper-case
%f Long file name without extension e.g. C:\Development\Flowcode\TestProgram.fcf becomes:
TestProgram
%F Short filename without extension e.g. C:\Development\Flowcode\TestProgram.fcf becomes:
TestPr~1
%d Long file path for the Flowcode file e.g. C:\Development\Flowcode\TestProgram.fcf becomes:
C:\Development\Flowcode
%D Short file path for the Flowcode file C:\Development\Flowcode\TestProgram.fcf becomes:
C:\Develo~1\Flowcode
%c0 Configuration byte count
%c1 Configuration byte #1
%c2 Configuration byte #2
%c3 Configuration byte #3
Compiler location
Sets the location of the file controlling compilation
Default:
C:\Program Files\Matrix Multimedia\Flowcode_AVR\Tools\MX_bats\avra.bat
Compiler parameters
Adds command line parameters when called from flowcode
Default:
%t "%D\%f.elf" "%D\%f.c" "%D\%f.lst"
Linker/Assembler location
Sets the location of the file controlling linking and assembly
Default:
C:\Program Files\Matrix Multimedia\Flowcode_AVR\Tools\MX_bats\avrb.bat
Linker/Assembler parameters
Adds command line parameters when called from flowcode
Default:
"%D\%f.elf" "%D\%f.hex"
Programmer location
Sets the location of the file controlling the programming of the target device
Default:
C:\Program Files\Matrix Multimedia\Flowcode_AVR\Tools\MX_bats\avrc.bat
Programmer parameters
Adds command line parameters when called from flowcode
Default:
%a avrispmkii usb "%f.hex" %cfg %c0 %c1 %c2 %c3
Use programmer to set configuration options
This box should be left unchecked
Configuration parameters
This box should be left empty. Configuration parameters are set and downloaded from the Chip->Configure menu.
Note: The above parameters assume you are using the AVRDUDE programming application and AVRISPmkII programmer. If you are using an alternative programming application or programmer you will need to consult the relevant documentation for the required parameters and settings.
File Viewer location
Sets the File viewer location for viewing C and Assembly files.
Set to Windows Notepad by default.
Default:
C:\WINDOWS\notepad.exe
File Viewer parameters
Adds command line parameters for the File viewer program
Default:
Blank. NO PARAMETERS.
Creating a new Macro
Select the New option from the Macro Menu or press Ctrl+M to create a new macro.
The Macro dialog will appear with the following sections for filling in information, and adding options:
Name
Enter a name for the macro. If the name that you enter for the new macro already exists, then Flowcode will prompt you for a different name.
Description
Enter a description of the macro and its functions.
Return type
Specify the return type, or "No return variable" if the macro does not return a value.
Parameters
Adds a list of parameters that are required to be supplied to the macro.
Set the Name and type of the parameters.
parameters can be added, edited or deleted.
Local Variables
Adds a list of variables that are required to be used by the macro.
This sets them to be macro specific so that similarly named variables in other macros do not accidentally modify the ones used in this particular macro.
Set the Name and type of the parameters.
parameters can be added, edited or deleted.
Local variables uses a similar dialog to that of the Parameters dialog.
Private Flag
When creating a new macro for a component using the customized code feature you will be given a tick box allowing the macro to be private. If the macro is set to be private then the macro will not appear in the main Flowcode component macro list. This is useful for creating invisible helper functions such as the LCD RawSend function.
Editing and deleting macros
Edit or delete existing macros by selecting the Edit/Delete option from the Macro menu. Flowcode will display a list of its macros. Choose the name of the macro from the list and then either press the Edit or Delete buttons.
When editing a macro, Flowcode will open the window containing the macro to allow you to edit it.
When deleting a macro, Flowcode will check that the macro is not being called by any of your icons.
Input icon properties
Input icons check the specified port and/or bits for their value and then place the resulting value into the specified variable.
Display Name
The name of the icon that appears on the flowchart.
Variable
Select the name of the variable that you wish to input the port state into.
Variables button
This button brings up the variables dialog window allowing you to select an existing variable or to create a new one.
Port
Select from a list of the ports available on the target microcontroller
Single Bit
Use this option to read the state of a single bit of the port.
When the state of a single bit is true the value of that bit is passed as its value.
Entire Port
Use this option to read the value of the entire port into the variable.
Use Masking
When masking is used, it is possible to read only certain bits into a variable. This is useful when some bits of the port are configured as outputs.
When a mask is used only the values of the selected bits are read.
See the Using Masks page for more detail.
Output icon properties
Output icon send the value or variable to the specified port and/or bits.
The output is received at the port in binary format.
Display Name
The name of the icon that appears on the flowchart.
Variable or value
Select the name of the variable or a numeric value that you wish to output to the port.
Numeric values can be in decimal (unmarked) or in HEX format (preceded by 0x) e.g. 255 or 0xFF.
Variables button
This button brings up the variables dialog window allowing you to select an existing variable or to create a new one.
Port
Select from a list of the ports available on the target microcontroller
Single Bit
Use this option to write to a single bit of the port.
If a true (non zero) value is sent to the bit the bit is set (turned on), otherwise the bit is cleared (turned off).
Entire Port
Use this option to write the variable or value to the entire port.
Use Masking
When masking is used, it is possible to write to only certain bits of a port. This is useful when some bits of the port are configured as inputs and you wish to leave these bits unchanged.
With masking only the selected bits receive their value, all non selected bits are not affected.
See the Using Masks page for more detail.
Connection point icon properties
Connection icons are used to link from one part of a flowchart to another.
When the flowchart reaches the jump point it jumps to the matching connection point and then continues execution.
Connection icons are used in pairs, part one is the connection point - the point in the flowchart to jump to. Part two is the jump point - the point in the flowchart to jump from. Both parts share a connection letter - in this case 'A'. Several jump points can reference one connection point.
Part one: the connection point
Display Name
The name of the icon that appears on the flowchart.
Label
The text that will be displayed on the connection point allowing for meaningful labels to be created.
Part two: the jump point
Display Name
The name of the icon that appears on the flowchart.
Jump to Connection Point
Select the connection point definition that you wish to jump to. This option is not available if the icon is the definition of the connection point rather than a jump.
Editing component connections
To edit how an external component is connected to a microcontroller, first select the component in the panel and then click on the connections button in the properties tab. The Component Pins Connection dialog will appear allowing the connections to be viewed and edited.
Pin Name
The names of the pins of the external component are shown in this column along with a graphic image indicating the status of the connection. A green tick indicates that the connection is OK. A red cross indicates that the pin is not currently connected to the microcontroller but needs to be for the device to function properly. A yellow question mark indicates that the pin is unconnected but that it is not essential to the correct functioning of the device.
Port
The microcontroller port that an external pin is connected to is shown in this column.
Bit
The microcontroller port bit that an external pin is connected to is shown in this column.
Status
Status information about a pin is displayed here. This may include details of possible conflict between devices connected to the same microcontroller pin. In addition, certain components must connect some pins to the same port as other pins in the device. In this case, the status area displays this information and the user is unable to change the port in the Connect to section
Connect to
Use these lists to determine the microcontroller pin to connect to. If a list in unavailable then this means that the pin's connection is determined by that of another pin. A message will appear in the status information if this is the case.
To change the connection first highlight the pin by clicking on a pin under Pin Name.
Call Stack Window
The call stack window becomes active during flowchart simulation and is used to monitor the progress of the microcontroller as the execution enters and leaves macros in the program. The call stack window also supports the ICD mode allowing for the stack to be read directly from the microcontroller as it runs. This is useful for detecting and troubleshooting call stack overflows.
Editing Key Mappings
Key mappings allow you to use the keyboard keys 0 to 9 to control components attached to the microcontroller. For example if you have a bank of 8 push switches connected to the microcontroller, you could map the keys 1 to 8 to mimic the pushing and releasing of these switches when the flowchart is simulated.
To set up or change key mappings, select the Key Mappings option from the Edit menu. For each numeric key, you can select a component and for each component, you can select the individual element that you wish to control with that key. For example if you wish to use the '0' key to control the 5th switch in a component named 'Switches1' then select 'Switches1' in the Component list for Key 0 and then select 5 in the Element list for Key 0.
Key
The key on the number keypad that you wish to map.
Component
The attached component that you wish to map the key to.
Element
The individual element (Switch etc.) that you wish to bind the key to.
Elements are numbered sequentially in the same order as on the component.
Components with scrollbars use elements 1 and 2 to increase/decrease the scrollbar value.
Using Key mapping with elements that toggle will toggle the element on/off.
Using key mapping with press to make elements will send the element into its high, active, state when the key is pressed. Releasing the key will return the element to its low, inactive state.
Using key mapping with scrollbars will increase/decrease the scrollbar value.
Loop icon properties
Loop icons are used to repeat a task until specified conditions are fulfilled, or to perform the loop a set number of times.
Note that you will need to add calculation icons that modify the variables used for the condition in order for the condition to be fulfilled.
Display Name
The name of the icon that appears on the flowchart.
Loop while
Loops the program until the specified condition becomes true.Enter the conditions which will fulfill the loop.
(Setting the test condition to something that is always true will make the loop repeat forever e.g. While 1)
Variables button
This button brings up the variables dialog window allowing you to select an existing variable or to create a new one.
Test the loop at the:
Select whether you wish the loop to be tested at the start or at the end of the loop.
Can be set to check the condition at the start of the loop or at the end of the loop.
Loop count
Sets the loop to loop through a set number of times.
Count must be a whole number between 1 and 255.
Infinite loops
Sometimes a task needs to be repeated continually. One useful way of achieving this is to have an infinite loop.
Setting the test condition to something that is always true will make the loop repeat forever e.g. While 1
Comment icon properties
You can add comments to your code with the Comments icon.
Drag the icon to where you want it and add your comments in the icons property box.
Note that the icon is off to one side of the flowchart, as it does not need running so is not a part of the flow as such.
Comments allow users to leave notes in their code explaining functions, explaining variable settings etc., or for any other documentation task that they feel is needed. Leaving comments is a good idea as it helps others understand your code.
Switch icon properties
Switch icons are similar to decision icons only instead of two possible outcome branches (Yes, No) there are up to eleven.
They are particularly useful for tailoring your program to react in different ways based on an input variable.
Display Name
The name of the icon that appears on the flowchart.
Switch
This is the input parameter variable that is used to determine the branch of the switch that will be executed at run time.
Variables button
This button brings up the variables dialog window allowing you to select an existing variable or to create a new one.
Case options
Up to ten branches can be defined for the switch icon. The switch branches are enabled by ticking the tick boxes next to the values. The value in the case box is the value that is used to trigger that particular branch of the switch icon. If none of the values match the input parameter variable then the default branch of the switch case is used.
Watch Window
The watch window is used as a simulation tool to monitor the status of the variables used in your program.
Variables are added to the watch window by right clicking the window and selecting a variable from the current variable list.
If ICD Mode is enabled then the values shown in the watch window are taken directly from the running target microcontroller.
The watch window can also be used to pass or receive values of memory locations and registers on board the target microcontroller.
Viewing code output
Flowcode allows users to view the C and Assembly code produced by Flowcode.
To view the code select the appropriate entry from the Chip menu.
Chip > View C Code
Opens the C Code up in the File Viewer specified in the Compiler options (Windows Notepad by default).
Chip > View ASM Code
Opens the ASM Code up in the File Viewer specified in the Compiler options (Windows Notepad by default).
Changing the default File Viewer
The File viewer settings are contained on the Compiler Options dialog.
To view the options select Compiler Options from the Chip menu.
Edit the File Viewer options to point to the desired editor, and set any command line parameters required for the viewer.
Saving Flowchart images
To save an image of the currently active flowchart select one of the sub menu options from the Save Image menu item in the File menu.
Save Image
Save as Bitmap
Save as JPEG
Saves an image of the program to the specified file in the format chosen.
Note that the current zoom rate is used to determine the resolution of the image saved. If you need high quality images for printing then increase the zoom rate.
Undo and redo
Flowcode has an Undo and Redo feature to enable users to correct mistakes such as accidentally deleting an icon etc.
To Undo an action click on the Undo button on the Toolbar, select Undo from the Edit menu, or use the shortcut key Ctrl-Z.
To Redo an action click on the Redo button on the Toolbar, select Redo from the Edit menu, or use the shortcut key Ctrl-Y.
Changing variable types
Name Change
The name of any selected variable can be changed by editing the 'Name of new variable' property. The change will affect all instances of the original variable name in the Flowcode program.
Type Change
Variable types can be swapped between BYTE and INT types.
Global options
Allows users to set display options for Flowcode.
Font name
Allows users to set the font used by Flowcode
Font size
Allows users to set he default font size used by Flowcode
Icon color
Allows users to select the color used to fill the Icons.
A selection of colors is presented in the drop down list.
Select a color, or select More... for the windows Color editor.
Using the Windows color editor
Select a color from the pallette or click on Define custom colors to create new colors for the custom pallette.
Either edit the values or select an area of the color chart, and a point on the color bar to create custom colors.
Background color
Allows users to select the background color in a similar way to selecting icon color.
Background Pattern
Allows users to select a pattern for the main flowchart window background.
Show text inside icons
Controls the text inside the flowchart icons allowing it to be displayed or hidden.
Hide Annotations
Controls the bubble annotations next to the flowchart icons allowing them to be displayed or hidden.
Skin
Allows users to control the overall look and feel of the flowchart and the flowchart icons.
Use tabs
Enables or disables the tabs on the flowchart macro windows.
Use alternate tab style
Modifies the look of the tab style.
Use colored tabs
Controls if the tabs are all one color or multicolored.
Print in color
Allows the flowchart to be printed out in color or greyscale.
Show tooltips as C Code
If you select the 'Show tooltips as 'C' Code' box then when your mouse pointer is placed over the top of a Flowcode icon you will see the C equivalent of that icon in a bubble window.
Override Language
Allows the user to override the default Flowcode language settings and to display Flowcode in the specified language.
Select the language from those available on the drop down list.
Note: The relevant language packs need to be installed for Flowcode to enable that particular language.
Component Macros
Macros have now been split into Macros and Component macros.
Component macros are pre-defined macros supplied with the components. For example LCD macros are used to display numbers and characters on the LCD display.
Component macros are only available for use with that particular component.
Component macros have hatched outer bands on the icon.
Macros are those designed and created by the user.
Macros can be exported and imported allowing users to build up macro libraries of common or important tasks.
On Macros the outer bands are clear and not hatched.
Adding a component macro
Select the component and macro to use
Select the component from the list of attached components on the left, and select the macro to use from the list on the right.
Add in any parameters required, and select a return value if required.
Parameters
If the device macro requires any parameters then these can be entered in this field. They can be numeric values or existing variables. Each variable or value must be separated by a comma.
The parameter details will list the parameter type. Parameters must be of the required type to be accepted.
Note that a full set of parameters must be provided.
Variables button
This button brings up the variables dialog window allowing you to select an existing variable or to create a new one.
Return value
If the device macro returns a value then you can assign that value to an existing variable for use later in the flowchart. If the function returns a value but you do not wish to retrieve it then leave this field empty.
The variable type of the return value will be listed. A variable of the specified type must be used to accept the return value.
PICmicro Custom Interrupts
Here are a few examples for such interrupts using PICmicro chips. To create interrupts that are not shown below you will have to refer to the device datasheet. Once the code has been placed into the custom interrupt properties dialog, the interrupt can be enabled and disabled like any of the standard Flowcode Interrupts.
USART receive - This can be nicely integrated with the Flowcode RS232 component.
Comparator - Example of the use of a function not supported by Flowcode.
Timer1 rollover - An example of the use of another unsupported, but potentially useful, function.
Target PIC Processor ( PIC16F877A )
(Note: For other PIC devices you may have to refer to the device datasheet to obtain the correct code)
USART receive
The Flowcode RS232 component can be used to set the Baud rate and configure the mode of operation, and the ReceiveRS232Char function can be used in the handler macro to read the data (clearing the interrupt).
Enable code:
intcon.PEIE = 1; // Enable peripheral interrupts
intcon.GIE = 1; // Enable global interrupts
pie1.RCIE = 1; // Enable USART receive interrupts
Disable code:
pie1.RCIE = 0; // Disable USART receive interrupts
Handler code:
if (pir1 & (1 << RCIF))
{
FCM_%n(); // call selected macro
clear_bit(pir1, RCIF); // clear interrupt
}
Analogue comparator
Enable code:
intcon.PEIE = 1; // Enable peripheral interrupts
intcon.GIE = 1; // Enable global interrupts
pie1.CCP1IE = 1; // Enable Capture Compare interrupts
Disable code:
pie1.CCP1IE = 0; // Disable Capture Compare Interrupts
Handler code:
if (pir1 & (1 << CCP1IF))
{
FCM_%n();
clear_bit(pir1, CCP1IF);
}
The state of the comparator input can be read into a Flowcode variable 'compstate' with the following C code line:
FCV_COMPSTATE = CCPR1L | ( CCPR1H << 8 );
** compstate must be declared as an integer variable **
Timer1 rollover
Enable code:
t1con = 0x79; // Start timer with Internal clock source, prescaler = 1:8
intcon.PEIE = 1; // Enable peripheral interrupts
intcon.GIE = 1; // Enable global interrupts
pie1.TMR1IE = 1; // Enable Capture Compare interrupts
Disable code:
pie1.TMR1IE = 0; // Disable Capture Compare interrupts
Handler code:
if (pir1 & (1 << TMR1IF))
{
FCM_%n();
clear_bit(pir1, TMR1IF);
}
The captured 16-bit count value can be read into a Flowcode variable 'captval' with the following C code line:
FCV_CAPTVAL = TMR1L | ( TMR1H << 8 );
** captval must be declared as an integer variable **
String manipulation icon properties
The properties box of the String manipulation icon allows users to manipulation, create and edit strings in a similar manner to how the calculation icon allows users to manipulate numeric variables.
Enter the function code and string variable names into the text box to manipulate the strings.
The variables and Function buttons allow the user to add those elements into the edit box window.
Strings
Strings are arrays of BYTE ASCII character values.
String arrays are composed of the array name and an array element variable.
MyString[24] for instance is an array called MyString that is 24 characters in size.
Creating a string
Strings are created in the Variables screen along with other variables.
To create a string enter the String array name and tick the String option.
To set the array size enter the desired size inside square array brackets.
If no size is specified the string will be created with the default size of 20 characters.
Resizing the string
To resize the string open the variables window, select the string to resize and select EDIT.
Enter the new size for the array.
Note that you may need to alter your program code to accommodate the size change.
String manipulation functions
The String functions are a set of string manipulation functions that can be used to edit, change and examine the strings.
Clicking on a function adds the base code to the edit box window. The user can then edit this base code with the variables required.
See the String Manipulation Functions page for details on the available details.
String manipulation functions
The String functions are a set of string manipulation functions that can be used to edit, change and examine the strings.
Clicking on a function adds the base code to the edit box window. The user can then edit this base code with the variables required.
Example Strings used in explaining the functions below:
Str1[20] = "Hello "
Str2[10] = "World"
TestStr[20]
=
Changes the string to the string given. If the array.
If the string is longer than the array size then any extra characters are lost.
TestStr = Str1 + Str2
TestStr is now "Hello World"
+
Concatenates the two string together in the order presented from left to right.
If the resulting string is longer than the array size of the receiving string then any extra characters are lost.
TestStr = Str1 + Str2
TestStr is now "Hello World"
ToString$(value)
Changes the numeric value to a String.
TestStr = ToStr$(1234)
TestStr is now "1234"
ToUpper$(string)
Changes all letters to upper case.
TestStr = ToUpper$(Str1)
TestStr is now "HELLO "
ToLower$(string)
Changes all letters to lower case.
TestStr = ToLower$(Str1)
TestStr is now "hello "
Length$(string)
Retrieves the length of the string.
This is not the Array size, but the number of characters in the array before a Null character is encountered.
RetVal = Length$(Str1)
RetVal is now 6
Note: Str1 array size is 20, but has a String of only 6 characters currently assigned to it hence the return value of 6.
Left$(string, size)
Retrieves a substring from the string of size characters starting from the leftmost character.
If the length of the string used to store the result is less than size of the substring returned then any extra characters are lost.
TestStr = Left$(Str1, 3)
TestStr is now "Hel"
Right$(string, size)
Retrieves a substring from the string of size characters starting from the rightmost character.
I.e. a size of 4 retrieves the 4 rightmost characters.
If the length of the string used to store the result is less than size of the substring returned then any extra characters are lost.
TestStr = Right$(Str1, 3)
TestStr is now "lo "
Mid$(string, start, size)
Retrieves a substring from the string starting at position start of size characters.
If the length of the string used to store the result is less than size of the substring returned then any extra characters are lost.
TestStr = Mid$(Str1, 2, 3)
TestStr is now "llo"
Compare$(string1, string2, compare_type)
Compares the two strings, parameters 1 and 2, and returns a BYTE value corresponding to the following results:
0 = strings are identical
1 = string1>string2
255 = string2>string1
The 3rd parameter, compare_type, determines whether or not the check is case sensitive. values for compare_type are:
0 = case sensitive
1 = case insensitive.
Examples
Str1 = "ABC"
Str2 = "abc"
RetVal = Compare$(Str1, Str2, 0)
RetVal is now 255 as Str2 is later in the ASCII sequence.
RetVal = Compare$(Str1, Str2, 1)
RetVal is now 0 as when case insensitive the two strings are identical.
Str2 = Str1
RetVal = Compare$(Str1, Str2, 0)
RetVal is now 0 as both strings are identical.
FloatToString$( float )
Converts a floating point number into a string.
float = Floating point number to convert.
string = String variable to hold the conversion data.
string = FloatToString( float )
NumberToHex$( number )
Converts a byte or int number into a hexademial string.
number = byte or integer number to convert.
string = String variable to hold the conversion data.
string = FloatToString( INT )
StringToInt$(string)
Converts a string of numeric ASCII data into an integer numeric data value.
string = String variable containing numeric ASCII data.
returns numeric data from the string in decimal form.
number = StringToInt$( string )
StringToFloat$( string )
Converts a string of numeric ASCII data into a floating point variable.
string = String variable containing numeric ASCII data.
returns numeric data from the string in floating point form.
float = StringToFloat$( string )
Supplementary code
Flowcode is often used by C programmers as a method of managing their code and allowing less experienced team members to take advantage of more complex C or Assembly code routines. If you have blocks of C or Assembly code that contain routines, definitions, lookup tables, etc. that you need to call later in the program then you should use this feature. This is an advanced feature that requires an understanding of C or Assembly language.
Definitions and function declarations
The first section, Definitions and function declarations, is added at the beginning of the C Code to allow users to add in defines, includes, function declarations and any other initialization code needed. This section is placed at the beginning of the generated C file to allow the code to be visible to all parts of the program.
The second section, Function implementations, allows for the addition of the main function code.
The code is split into these two sections to allow every Flowcode macro to use any of the supplementary functions defined, and to allow these supplementary functions to use any user or component macros that exist in the Flowcode program. It also ensures that supplementary functions can call other supplementary functions.
Warning: If Flowcode fails to compile you may need to examine the supplementary code for errors.
Note also that Flowcode does not simulate C Code, so programs that make use of supplementary code may not simulate correctly.
Example:
To create a simple 'C' function that adds 2 parameters together, put the function's declaration (or 'prototype') in the first section:
short AddNumbers( short i1, short i2);
In the second section, put the actual implementation of the function:
short AddNumbers( short i1, short i2)
{
short iReturn = i1 + i2;
return (iReturn);
}
To call this function from a flowchart, add a 'C' icon and put the following code into it:
FCV_RESULT = AddNumbers( 5, FCV_MYVAR);
This example would set the Flowcode variable "Result" to "MyVar" plus 5.
Parameters and Local variables
Parameters and local variables are used to send data to a macro, and to retrieve a result from the macro.
Parameters
Adds a list of parameters that are required to be supplied to the macro.
Set the Name and type of the parameters.
Parameters can be added, edited or deleted.
Local Variables
Adds a list of variables that are required to be used by the macro.
This sets them to be macro specific so that similarly named variables in other macros do not accidentally modify the ones used in this particular macro.
Set the Name and type of the local variables.
Local Variables can be added, edited or deleted.
Adding a parameter or local variable
Click the ADD button to bring up the Variable creation screen.
Select the type of variable to be used, and enter a unique name for the variable.
Note: the name needs to be unique to the macro, but several macros could have the same local variable name e.g. Count in their variables list.
Editing a variable
Select the EDIT button next to a variable to edit the variable type and name.
Deleting a variable
Select the DELETE button next to a variable to delete the variable.
Project options
The project options menu defines settings related to the current Flowcode project. The menu is available under the Flowcode Edit menu.
Target
Defines the microcontroller that the Flowcode compiled program will be run on.
Clock Speed
Must be set to match the hardware clock frequency so that delays and other timing critical features run at the correct speed on the hardware. Several options exist for the clock speed in the drop down menu however any value of clock speed can be entered directly into the text field.
Simulation Speed
Defines the speed of the flowchart simulation. Slowing down the simulation allows for flowchart icons to become highlighted as the simulation runs.
Use Supplementary Code
Allows any supplementary code to be included into the program. This is useful for including external C or Assembler files into your programs.
Auto Clear Watchdog
This is used to automatically clear the watchdog timer every time a component macro is called which will stop the target device from detecting a false stop condition and resetting.
ICD Mode
Switches on the ICD functionality. Requires a v7 EB006 Multiprogrammer or a Matrix ICD tool.
Breakpoint Count
Defines the maximum number of breakpoints allowed in your program.
Callstack Depth
Defines the maximum stack size in you program. This will always be 8 unless you have enabled the BoostC software stack.
Communication Speed
Defines the number of iterations to wait before timing out. This value is based on the clock speed of the target device and is automatically updated.
Override ICD Pins
Allows any free I/O pins on the target microcontroller to be used for the ICD functionality. Compatible with the matrix ICD tool.
Restore Defaults
Restores all of the ICD settings back to their default values.
Component toolbar order and visibility
The order and visibility of the Components in the Components toolbar can be customized in the Components dialog.
This allows users to group similar components together, m
To open the Components dialog select COMPONENTS from the VIEW menu.
Visible components have a tick in the checkbox next to their name.
To hide a component uncheck the box next to its name.
To move a component up or down in the viewing order select the component and click on the Up and Down arrow buttons to alter its order in the sequence.
AVR Custom Interrupts
Target AVR Processor ( ATMEGA8, 16, 32 )
(Note: For other AVR devices you may have to refer to the device datasheet to obtain the correct code)
USART receive
The Flowcode RS232 component can be used to set the Baud rate and configure the mode of operation, and the ReceiveRS232Char function can be used in the handler macro to read the data (clearing the interrupt).
Enable code:
UCSRB |= ((1 << RXCIE) | (1 << RXEN)); // enable USART receiver and receive interrupts
Disable code:
UCSRB &= ~(1 << RXCIE); // disable USART receive interrupts
Handler code:
ISR(USART_RXC_vect) // USART receive vector
{
FCM_%n(); // call selected macro
}
Analogue comparator
Enable code:
SFIOR &= ~(1 << ACME); // disable multiplexer input
ACSR |= (1 << ACIE); // enable comparator interrupts - interrupt when comparator output toggles
Disable code:
ACSR &= ~(1 << ACIE); // disable comparator interrupts
Handler code:
ISR(ANA_COMP_vect) // analogue comparator interrupt vector
{
FCM_%n(); // call selected macro
}
The state of the comparator input can be read into a Flowcode variable 'compstate' with the following C code line:
FCV_COMPSTATE = ACSR & (1 << ACO);
Timer1 rollover
Enable code:
TCCR1B = 0x45; // positive edge trigger with no noise canceler, prescaler = /1024
TIMSK |= (1 << TICIE1); // enable input capture interrupts
Disable code:
TIMSK &= ~(1 << TICIE1); // disable input capture interrupts
Handler code:
ISR(TIMER1_CAPT_vect) // input capture vector
{
FCM_%n(); // call selected macro
}
The captured 16-bit count value can be read into a Flowcode variable 'captval' with the following C code line:
FCV_CAPTVAL = ICR1;
** captval must be declared as an integer variable **
ARM Custom Interrupts
Target ARM Processor ( AT91SAM7S128 )
(Note: For other ARM devices you may have to refer to the device datasheet to obtain the correct code)
The official device datasheet is an invaluable source of information when dealing with custom interrupts, as are two header files,lib_AT91SAM7S128.h and AT91SAM7S128.h, which provide functions and definitions. These files are applicable to all the devices in the AT91SAM7S range.
The header files can be found in the \Tools\ Global folder of the Flowcode installation. These files must not be modified!
Enable Code:
This command enables the receive interrupt of USART1.
AT91F_US_EnableIt(AT91C_BASE_US1,AT91C_US_RXRDY);
AT91F_US_EnableIt()
This library function can be used to enable any of the interrupts generated by a USART. AT91SAM7S16 and 32 devices have only one USART, the other devices in the range have two. The function writes to the interrupt enable register of the designated USART.
There is an AT91F_US_DisableIt() function that can be used in the same way in the Disable Code section to disable the interrupt.
AT91C_BASE_US1
This is the system definition of the base address of the registers associated with USART1
AT91C_US_RXRDY
This is the system definition of the RXRDY (Receive Ready) bit in a USART interrupt enable register.
Handler Code:
This code section checks the identity of the peripheral device generating the interrupt and the interrupt event being generated. The Flowcode Custom Interrupt system receives two parameters when an interrupt is generated:
· Peripheral device identity number (periphID)
· Active interrupt flags (IFlags)
Active interrupt flags are those that have been both enabled and triggered.
if((periphID == AT91C_ID_US1) && (IFlags & AT91C_US_RXRDY))
{
FCM_%n();
}
FCM_%n():
Thisis converted into the name of the macro selected in the 'Will call macro' box of the interrupt properties panel.
periphID:
This parameter is the system identification number of the peripheral device generating the interrupt. The following peripheral devices are supported by Flowcode as custom interrupts;
AT91C_ID_PIOA Parallel IO Controller
AT91C_ID_ADC Analog-to-Digital Converter
AT91C_ID_SPI Serial Peripheral Interface
AT91C_ID_US0 USART 0
AT91C_ID_US1 USART 1
AT91C_ID_TWI Two-Wire Interface
AT91C_ID_PWMC PWM Controller
AT91C_ID_TC0 Timer Counter 0
AT91C_ID_TC1 Timer Counter 1
AT91C_ID_TC2 Timer Counter 2
IFlags:
This parameter contains all the interrupt flags that are being generated by the peripheral device and have been previously enabled.
AT91C_US_RXRDY:
In addition to being the definition of the interrupt enable flag, this also acts as the definition of the interrupt request flag.
Selecting Compiler Options (ARM)
Substitute variables used by Flowcode
%T Target name as written e.g. AT91SAM7S128
(generally used by the compiler)
%t Target name forced to lower-case
%p Target name forced to upper-case
%a Alternative target name as written e.g. m32
(generally used by the programmer)
%A Alternative target name forced to upper-case
%f Long file name without extension e.g. C:\Development\Flowcode\TestProgram.fcf becomes:
TestProgram
%F Short filename without extension e.g. C:\Development\Flowcode\TestProgram.fcf becomes:
TestPr~1
%d Long file path for the Flowcode file e.g. C:\Development\Flowcode\TestProgram.fcf becomes:
C:\Development\Flowcode
%D Short file path for the Flowcode file C:\Development\Flowcode\TestProgram.fcf becomes:
C:\Develo~1\Flowcode
%c0 Configuration byte count
%c1 Configuration byte #1
%c2 Configuration byte #2
%c3 Configuration byte #3
Compiler location
Sets the location of the file controlling compilation
Default:
C:\Program Files\Matrix Multimedia\Flowcode_ARM\Tools\MX_bats\arm7comp.bat
Compiler parameters
Adds command line parameters when called from flowcode
Default:
"%f" "%D"
Linker/Assembler location
Sets the location of the file controlling linking and assembly
Default:
C:\Program Files\Matrix Multimedia\Flowcode_ARM\Tools\MX_bats\arm7link.bat
Linker/Assembler parameters
Adds command line parameters when called from flowcode
Default:
"%f"
Programmer location
Sets the location of the file controlling the programming of the target device
Default:
C:\Program Files\Matrix Multimedia\Flowcode_ARM\Tools\mLoader.exe
Programmer parameters
Adds command line parameters when called from flowcode
Default:
"%f.bin"
Use programmer to set configuration options
This box should be left unchecked
Configuration parameters
This box should be left empty. Configuration parameters are set and downloaded from the Chip->Configure menu.
Note: The above parameters assume you are using the AVRDUDE programming application and AVRISPmkII programmer. If you are using an alternative programming application or programmer you will need to consult the relevant documentation for the required parameters and settings.
File Viewer location
Sets the File viewer location for viewing C and Assembly files.
Set to Windows Notepad by default.
Default:
C:\WINDOWS\notepad.exe
File Viewer parameters
Adds command line parameters for the File viewer program
Default:
Blank. NO PARAMETERS.
Hosting a Vnet
Once there is a Vnet server running and started on your network or your PC you can start to create Flowcode networks.
Open Flowcode on the machine you wish to host the Vnet, click then Vnet menu and select Create.
This will pop up the Create Vnet window, you will need to fill out the following details.
Client Name - Assign a name for your Flowcode instance.
Vnet Name - Assign a name for your Vnet network.
Clicking create will register the Vnet with the Vnet server software allowing other instances of Flowcode to access the Vnet.
To finish hosting the Vnet you can click on Vnet menu in Flowcode and select Quit.
Joining a Vnet
Once there is a Vnet server running and started on your network or your PC and there is a instance of Flowcode hosting a Vnet you can start to attach other instances of Flowcode to the Vnet.
Open Flowcode on the machine you wish to join the Vnet, click then Vnet menu and select Join.
This will pop up the Join Vnet window, you will need to fill out the following details.
Client Name - Assign a name for your Flowcode instance.
Vnet Name - The Vnet name you assigned when hosting the Vnet should appear in the drop down menu.
Clicking join will register your connection with the Vnet host and the Vnet server software allowing other instances of Flowcode to see your exposed components.
To leave the Vnet you can click on Vnet menu in Flowcode and select Quit.
Exposing nodes to the Vnet
Once you have created or joined a Vnet you are ready to start exposing Flowcode nodes to the network. To do this add components to your Flowcode program as you would normally do and then click on the Vnet menu and select Manage Nodes.
You will then be presented with a list of all the Vnet compliant nodes that are currently present in your program. These nodes can range from components through to the I/O pins on the device.
Selecting a node and clicking expose will make that node available on the Vnet. Clicking hide will remove the node from the Vnet.
Customize Code Window
Each macro in the list has a set of properties which detail a few key features.
InBuilt - Details if the macro is from the original component code file or is it a user generated component macro.
Private - Details if the macro can be called from Flowcode or if it is hidden.
Customized - Details if the macro has been customized by the user.
New Macro
Allows new component macros to be created for that component.
This could be used to combine multiple component macros into one macro call or to provide extra functionality to the component.
See Creating a New Macro
Edit Details
Used to edit the details of any user created component macros.
See Editing and Deleting Macros
Edit Code
Brings up a syntax highlighted window containing the current component macro code.
See Edit Code Window
Delete Macro
Used to delete a user created component macro.
See Editing and Deleting Macros
Import
Loads a customized component macro from an external file allowing for customized components to be used in multiple Flowcode programs.
Export
Saves the selected customized component macro into an external file allowing for customized components to be used in multiple Flowcode programs.
Each component has three sections of code additional to the main functions that allows code specific to that component to be placed into a number of places in the main Flowcode C file.
[Defines] - Placed at the top of the C code file and used for defining parameters used in the main functions.
[Initialization] - Placed at the start of the Main function before any Flowcode icons are called and used for initialization purposes.
[Interrupt] - Placed in the main interrupt function allowing for specific interrupts to be trapped and serviced.
Edit Code Window
Edit Code Options
Revert to default - Reloads the code from the original component code file.
OK - Saves the new customized code into the Flowcode project file.
Cancel - Reverts to the last set of code used.
% Substitutions
Many Flowcode components have a % symbol followed by a small string eg %a dotted around in the component code.
These % symbols are used by Flowcode to make substitutions based on property pages and other factors such as clock speed.
In the final Flowcode C code output file the % substitutions are replaced with actual data.
A list of the substitutions for each component can be found at the top of each component code file along with a brief description of what the substitution is doing.
Customizing Component Macro Code
Every component now has the ability to allow its macros to be edited directly from within Flowcode.
This allows components to be tailored directly to suit your needs without having to change the underlying C code component files.
Component macros can also be created to allow for customized operation of the component.
It should be noted that customized macros or user created macros will not simulate.
Component customization is done by first selecting the component you wish to edit in the panel.
Then if the properties window is already open you can click the custom code property.
If the properties window is not open then you can right click the component you wish to edit and click properties.
You will now be faced with a list of the components macros including any hidden or private macros used in the configuration or initialization of the component. Each of the component macros can now be edited and saves as well as allowing extra customized macros to be added to the component.
Customize Code Window
Edit Code Window
Text Properties
Caption - Contains the text that is used on the panel.
Position - Specifies the location of the text on the panel.
Font - Controls the color, size and font used for the panel text.
Image Properties
Position - Specifies the location of the text on the panel.
Font - Controls the color, size and font used for the panel text.
Stretch - Allows the image to be stretched and scaled which allows the size and proportional control properties to appear.
Proportional - Allows the scale ratio of the image to be locked.
Size - Controls the size of the Image
Shape Properties
Size - Controls the size of the shape.
Position - Specifies the location of the shape on the panel.
Shape - Specifies the type of shape used on the panel. Shapes include Circle, Rectangle, Rounded Rectangle, Ellipse, Square, Rounded Square.
Stroke - Defines the color and style of the outside line.
Fill - Defines the color and style of the fill color.
Bevel Properties
Size - Controls the size of the bevel.
Position - Specifies the location of the bevel on the panel.
Type - Specifies the type of bevel used on the panel. Predefined bevels include Inset, Raised, Frame, Horizontal Line, Vertical Line.
Foreground Stroke - Defines the color and style of the bevel foreground.
Background Stroke - Defines the color and style of the fill color.
Line Properties
Start - Specifies the start coordinate of the Line.
End - Specifies the end coordinate of the Line.
Stroke - Specifies the color and width of the Line.
New In Version 4
The following is a list of major changes in version 4.
Component improvements
• New components including Stepper, Servo, Speech...
• Improved component functionality including ADC, RS232, I2C, PWM...
• Component simulations are more flexible and customizable
• Component macros are customizable
• Component categorization
Software features
• Virtual Flowcode Networks
• In Circuit Debugging (ICD)
• Variables watch window can display real time variable values using ICD
• Variables watch window can display real time device register values using ICD
• Floating point arithmetic support
• Read only user macros
• Delays in microseconds
• Watchdog timer now supported by delays and components
• Floating point and string conversion functions
• Hexadecimal ASCII conversion functions
• Built in syntax highlighted code editor
GUI improvements
• New improved graphical interface
• Simulation panel
• Complete icon text shown in annotations
• Tabbed windows
• New Skins
• Background themes
• Improved Icons
Icon improvements
• New switch case icon
• New component icons and simulation graphics
• Connection points can be assigned meaningful labels
Chip compatibility
• Extra microcontroller targets supported directly from Flowcode
• Extra Interrupts supported as standard for the target devices
• Increased support for third party programming tools
Vnet connection diagram
Once a Vnet has been created and instances of Flowcode have been added you can start to organize the structure of the Vnet. To do this you must use the instance of Flowcode that created the Vnet. Click on the Vnet menu and select View Diagram. This will bring up a blank window indicating that your Vnet currently has no connections.
Right clicking the diagram and selecting properties will bring up the connection properties.
Here you can see the instances of Flowcode that are currently connected to the Vnet. Selecting a Flowcode instance and clicking add to diagram will allow the instance to appear on the connection diagram. Note that the Flowcode instances on the diagram show the components that we exposed using the manage nodes menu.
Once you have added the instances you can begin connecting up the components. To connect a component begin by clicking on the component and a small square will appear inside the component box.
Next click away from the component and a line will appear. Continue creating lines until you have reached the node you wish to connect to.
Repeat this process until your Vnet is connected up correctly. Please note you can connect more then 2 components to a single branch and you can also connect multiple components from the same instance onto the same branch.
Once you have finished assigning the connection on the Vnet host instance of Flowcode you must right click the Vnet diagram and select save. This will confirm your connections and allow the Vnet operation to begin. You should also now be able to see the saved Vnet diagram on the other instances of Flowcode that are part of the Vnet.
Simulating the Vnet
Once your Vnet has been started and connected up you are ready to start simulating. The components will act as if they are connected with each other as they would do in a real system and allow for multi-node systems to be debugged and tested before any actual hardware is involved.
Simulation requires that each instance of Flowcode should be put into a ready to run state.
The instance of Flowcode that created the Vnet is responsible for checking that the other instances are ready and starting the simulation. To start the simulation click the run simulation button and the instance will check that all other instances are ready.
All other instances of Flowcode connected to the Vnet must be placed into a ready state by clicking the run simulation button. If there are instances of Flowcode connected to the Vnet that are not ready then the Vnet creator will report that not all instances are ready and will give you the option of continuing with simulation ignoring the missing instances or canceling to allow instances to become ready.
Adding support for a third party programming tool
Each version of Flowcode comes ready with a default programming tool. However it is fairly easy to change the settings in Flowcode to allow for third party programming tools to be used.
Flowcode's default programming tools.
Flowcode PIC - PPP
Flowcode AVR - AVRDUDE
Flowcode ARM - mLoader
The programming tool that is invoked when the compile to chip button is pressed is configured in the Chip menu under Compiler options.
For help with third party programming tools the first port of call should be to check our forums to see if anyone else has already tried the programming tool with Flowcode. If you are the first then if you wish you can post your findings for other users to benefit from.
Flowcode PIC
Flowcode PIC now comes with PICkit support built in. This can be enabled by configuring Flowcode during the install process or can be done manually at a later date. To enable the PICkit programmer you will have to change the programmer settings to match the following.
-PPIC%p -F%F.hex -M -A5 -H -B[INSTALLDIR]tools\PICkit2\
(where [INSTALLDIR] is the full path to the Flowcode installation directory).
Flowcode PIC also comes with a example for using the free microchip USB bootloader. Changing your target to the MCHP_FSUSB will automatically configure the programmer to use the Microchip PDFSUSB programming tool. Note - The USB bootloader firmware must be present on the device to allow the programming tool to connect correctly to the device.
Support for the Serial TINY PIC Bootloader is documented here.
Flowcode AVR
The AVRDUDE programming tool supports a number of third party programmers for more help and information please visit the AVRDUDE home page.
Flowcode ARM
Flowcode ARM comes with a set of precompiled bootloader files. This allows the matrix mLoader USB reprogrammable operation to be used on any third party ARM hardware.
Component Properties
To bring up a components attributes and properties you can right click on a selected component and click properties.
This will bring up a properties tab similar to this, tailored to your selected component.
The properties for the component are available by clicking the icon next to the Ext Properties list item.
Extra help for that specific component can be found by clicking the help button on the properties page.
In Circuit Debugging
It is now possible to do in circuit debugging using Flowcode and either our v7 EB006 or our ICD tool hardware. The ICD feature is enabled by ticking the ICD Mode tick box in the project options menu or by ticking the Debug mode option in the Run menu.
When ICD is enabled you must re-program the target device to allow the ICD code to be loaded onto the target device. Once the device has been programmed it will stay in a waiting state waiting for Flowcode to allow it to start running. Clicking the simulation run or step buttons in Flowcode will trigger the target device to react accordingly. Clicking the simulation stop button will reset the target device so that it restarts from the very start of the program.
Breakpoints, single stepping, variables watch window and other simulation features also work seamlessly with the ICD functionality.
Panel Properties
Size - Sets the height and width of the panel.
Position - Sets the position of the panel when in windowed mode.
Color - Sets the background color of the panel.
Image - Allows a image to be loaded as part of the panel background. Several options exist for positioning the image once it has been included into the panel.
Grid - Specifies a grid size and provides options for modifying the snap to grid and visibility settings.
Personalizing the simulation panel
The Panel in Flowcode is responsible for displaying the simulation of the running program. It can be personalized to have different background layouts, grids, background images etc.
Panel Properties
Double clicking the panel moves everything in the panel to a separate window and repeating this attach's the panel back to the main Flowcode window. When the panel is in windowed mode, it can also be re-attached by dragging the window over the main Flowcode window.
Vector shapes and images can be added to the Panel by using the Panel menu.
Add Text
Adds a piece of text to the panel.
Panel Text Properties
Add Image
Adds an image onto the panel.
Panel Image Properties
Add Shape
Adds a vector shape to be added to the panel.
Shapes available include - Circle, Rectangle, Rounded Rectangle, Ellipse, Square, Rounded Square.
Panel Shape Properties
Add Bevel
Adds a bevel shape to the panel.
Panel Bevel Properties
Add Line
Adds a line to the panel.
Panel Line Properties
Bring to Front
Brings the selected item in front of the other items on the panel.
Send to Back
Sends the selected item behind the other items on the panel.
Export
Allows a panel to be saves as an external file. This allows the same panel to be used across multiple Flowcode programs.
Import