Using Arduino Hardware with Flowcode for AVR

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

Post Reply
Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Using Arduino Hardware with Flowcode for AVR

Post by Sean »

Introduction
Arduino produce a range of target boards that can be directly programmed by Flowcode for AVR.
Boards.jpg
Boards.jpg (52.72 KiB) Viewed 42254 times
Hardware
Most of the Arduino boards include the standard 6-pin ISP header, allowing them to be programmed using the AVRISPmkII programmer. However, the boards also include USB connection hardware, and the microcontrollers contain bootloader programs that are compatible with the standard Atmel STK500 programming commands. They can therefore be connected directly to a PC using a USB cable and programmed with no additional programming hardware.

Th latest version of the Flowcode software can be downloaded from here: http://www.matrixtsl.com/flowcode.php

Three of the main targets are the Duemilanove and Mini (ATmega328) and Mega1280 (ATmega1280). The USB connection is handled by an FTDI USB to serial chip. Drivers for this device are widely available and are included in the free Arduino programming software download - available from http://www.arduino.cc.

The Duemilanove and Mega1280 have recently been replaced by the Uno (ATmega328) and Mega2560 (ATmega2560). The new boards have an alternative USB interface chip (a USB ATmega device) that requires different drivers to the FTDI chip. The newer drivers are also included in the latest Arduino download (Version 021).

The USB connection appears as a virtual COM (RS232) port. The new com port number needs to be identified to it can be used as a parameter by Flowcode.
DevMgr1.JPG
DevMgr1.JPG (41.13 KiB) Viewed 42254 times
Boards with the FTDI chip appear as 'USB Serial Port (COM2 in this case)
DevMgr2.JPG
DevMgr2.JPG (45.91 KiB) Viewed 42254 times
The newer boards identify themselves more clearly.

If the COM port number allocated by Windows is too high, the programming software might not be able to locate it. In this case the port number can be changed in the advanced properties of the driver. It might be necessary to reclaim a low numbered COM port that is indicated as being already in use!
PortAlloc.JPG
PortAlloc.JPG (64.99 KiB) Viewed 42254 times
The various board types require different programming baud rates - the information is available from files in the Adruino software download. The data received by the USB chip is programmed into the target microcontroller via one of its UARTs, under the control of the bootloader. The bootloader spends a short time checking for incoming programs each time it recovers from a RESET condition.

Programming
Programming is handled by AVRDUDE (as supplied with Flowcode for AVR), so the main changes required to allow Flowcode to program an Arduino board are a new batch file to control the programming, and new Location and Parameter information for the Programmer section of the Compiler Options panel.

The two new batch files must be copied into the Tools\MX_bats folder of the Flowcode AVR V4 installation.
ArduinoBatch.zip
(1.4 KiB) Downloaded 3193 times
Another requirement for programming the Arduino boards is the ability to reset the target device shortly before transmitting the new program - initiating the bootloader. This can be achieved manually, but the timing is quite critical and an alternative method is available under the control of the COM port.

The boards use a pulse on the RS232-DTR line to RESET the target device temporarily into programming mode. If programming begins within a short time period after the RESET, the chip is held in programming mode and the program is downloaded. If no program information is received within the time period, the device begins to run any program that is already in memory.

Direct control of the DTR line is not easily achieved, but the programming batch files contain DOS Mode commands that appear to generate the required pulse before the download process is started.

Programmer parameter string:
%a stk500v2 com8 115200 "%f.hex"
The com port value will need to match the port allocated by Windows (as described above).
The baud rate (115200 in this case) is dependent on the target board type.
The protocol (stk500v2 in this case) is also dependent on the target board type.

Uno = 115200 Baud, stk500
Duemilanove, Nano (ATmega328) = 57600 Baud, stk500
Diecimilia, Duemilanove, Nano (Atmega168) = 19200 Baud, stk500
Mega2560 = 115200 Baud, stk500v2
Mega1280 = 57600 Baud, stk500

See Arduino documentation for other options.

Programmer path strings:
C:\Program Files\Matrix Multimedia\Flowcode AVR V4\Tools\MX_bats\avrc_arduino1.bat
C:\Program Files\Matrix Multimedia\Flowcode AVR V4\Tools\MX_bats\avrc_arduino2.bat

The avrc_arduino1.bat file seems to work best with the older Arduino boards (FTDI USB chip):
The avrc_arduino2.bat file works with the newer Arduino boards (ATmega USB device):

The path information is based on a default Flowcode installation. If Flowcode has been installed at an alternative location, the path information must be modified as appropriate.

In some cases the programmer will fail on the initial download and AVRDUDE will then be unable to access the allocated COM port. If this happens, disconnecting and removing the power from the Arduino board, then re-connecting everything usually cures the problem.

Flowcode
The Arduino bootloader enables a UART in the target device to allow the program to be transferred. The two pins used by the UART are not available as normal I/O when the UART is enabled. To return the UART pins to normal use, the first instruction in the Flowcode program should be a C code icon containing the following line (for the Duemilanove and Nano boards, other target devices might have different register names):

UCSR0B &= ~((1 <<RXEN0) | (1 << TXEN0)); //disable UART0

Apart from this minor issue (only applicable if the UART port pins are required as programmable I/O) the boards can be sent any normal Flowcode program compiled for the appropriate device and clock speed.

Connections
Arduino boards make I/O connections available using header sockets. These allow some component leads to be inserted directly. The sockets also allow connection of the 'Shield' expansion boards. Some of these are for specific applications, but prototyping versions are also available.

Using a prototype Shield board it is possible to make the I/O connections available in a more convenient form. The example board pictured uses the standard Atmel 2x5 pin headers to make the I/O available as individual ports. Additional ribbon cables and converter PCBs then provide the D9 E-blocks connectors.
Display.jpg
Display.jpg (66.63 KiB) Viewed 42254 times
The D9 connectors could be soldered directly to the Shield board, or wired to headers and inserted directly into the sockets on the main board.

mhump711
Posts: 3
Joined: Thu Feb 02, 2012 2:17 pm
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by mhump711 »

Hi, I am trying to use what you have explained above but I am not able to get it to work. I am using the Arduino Uno and Flowcode 4.3. I downloaded the batch files and put them in the mx_bats folder. But I don't understand the Programmer Option changes that need to be made.

Thanks

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by dazz »

Hi i only have the free version of flowcode avr so cant check my answer out on my arduino, im assuming you want to change the programmer parameters mentioned in the article, i have attached a set of images to show how to do that, let us know if it works for you
Attachments
avr1.jpg
avr1.jpg (127.11 KiB) Viewed 39403 times
avr2.jpg
avr2.jpg (199.2 KiB) Viewed 39403 times
avr3.jpg
avr3.jpg (173.27 KiB) Viewed 39403 times
avr4.jpg
avr4.jpg (153.44 KiB) Viewed 39403 times
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

mhump711
Posts: 3
Joined: Thu Feb 02, 2012 2:17 pm
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by mhump711 »

Tried that Still didn't work I don't have stk500. So I not really sure what to do.

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by Sean »

STK500 is the standard programmer protocol used by the Arduino bootloader and supported by AVRDUDE (no STK500 hardware is required). There are some minor variations that are covered by AVRDUDE using the parameters stk500, stk500v2, etc.
The batch files supplied in the first post in this thread must be unzipped to the correct location in your Flowcode AVR installation, and the virtual COM port, allocated to the Arduino board by the PC, must be identified correctly.
The changes to the strings in the Flowcode programmer parameters are required to allow Flowcode to locate the appropriate batch file and pass the required port and protocol parameters.

mhump711
Posts: 3
Joined: Thu Feb 02, 2012 2:17 pm
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by mhump711 »

After lots of guessing I figured out what the settings need to be.

I am using Arduino Uno

Clock speed set to 16 MHz
I set the Fuse settings to a fuse calculator I found online

I used the batch file 'avrc_arduino2.bat' from above and changed the location to of the batch. I moved it to the tools\mx_bats.

Most importantly the parameter settings are the following:
%a arduino com9 115200 "%f.hex"

I hope this helps someone else.

User avatar
Benj
Matrix Staff
Posts: 15280
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4786 times
Been thanked: 4308 times
Contact:

Using E-blocks with Arduino Software

Post by Benj »

Hello,

Out of interest there is also a way to do the opposite which is to use E-blocks with the Arduino software and compiler using the standard AVRISP programmer.

http://arduino.cc/en/Hacking/Programmer

gadjet
Posts: 11
Joined: Thu Jul 05, 2012 8:43 pm
Has thanked: 1 time
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by gadjet »

Hi,
I've just downloaded the free flowcode 5 for AVR and would like to get it working on my UNO and then also use it for programming an ATTINY84 but before buying it I want to be sure I can get it to work.

With the blurb actually saying version5 was for use with the Arduino I thought it would be easy ......... no, nothing's ever easy.

I've tried all the combinations shown in this thread without any luck, has anyone got it working with the Arduino Uno or with a USBtiny programmer?

Cheers,
Phil

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by dazz »

Hi
im attaching a config file unzip it somewhere then simply open flowcode ,select build ,compiler options, import. then browse to where you saved the file select the fcs click ok, this will import the parameters and bat file, then simply in the parameters box change the com6 to the com port your arduinos on, finally click the save icon at the top

Regards
Dazz
programmer config.zip
(360 Bytes) Downloaded 1872 times
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

benrouse77
Posts: 26
Joined: Thu Jul 05, 2012 11:29 pm
Has thanked: 12 times
Been thanked: 1 time
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by benrouse77 »

Hi, need some help, I've just got the avr/arduino v5 flow code for home and can't compile to my arduino mega adk board. the avrdude seems to return an error code of 1 and not seems to crash???

not sure if this is the right place to ask as I couldn't find out how to start a new post

gadjet
Posts: 11
Joined: Thu Jul 05, 2012 8:43 pm
Has thanked: 1 time
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by gadjet »

dazz wrote:Hi
im attaching a config file unzip it somewhere then simply open flowcode ,select build ,compiler options, import. then browse to where you saved the file select the fcs click ok, this will import the parameters and bat file, then simply in the parameters box change the com6 to the com port your arduinos on, finally click the save icon at the top

Regards
Dazz
programmer config.zip
Dazz, thanks, I'll give that a try this afternoon and report back.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by dazz »

Benrouse77

Sign up to the v5 forums please.
Can you also explain your issues a bit more, does your flowchart compile to hex is it erroring there or erroring at the programming stage.
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

benrouse77
Posts: 26
Joined: Thu Jul 05, 2012 11:29 pm
Has thanked: 12 times
Been thanked: 1 time
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by benrouse77 »

Hi daz, can't figure our how to start a new post in v5. the error is in the programming stage, just can't get flowcode to recognise the arduino. I'm using flowcode v5 and an arduino mega adk. I've tried many different settings now and at one point I managed to almost work but the avrdude kept timing out tring to load the program. Could you send the correct config file I might need, tryed the one in the earlier post but no joy even setting the arduino to com6 or any othr port.

gadjet
Posts: 11
Joined: Thu Jul 05, 2012 8:43 pm
Has thanked: 1 time
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by gadjet »

benrouse77,
I've got to say that my experience is exactly the same as yours and I've even got two colleagues at work interested in Flowcode but they can't talk to the UNO either, I'll look into posting in the V5 forum, not tried yet.

I'm surprised that it doesn't work out of the box, considering that it even mentions Arduino in the product name!!

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by dazz »

Hi Benrouse77

Attached is the programmer file you asked for. make sure to change the com port to the one your mega is using, then try the following hold the reset button down and keep it down on the arduino mega then compile to chip, when the compiler gets to the status part , release the reset button on your mega and it should program, if you try to program and it keeps timming out keep pressing the reset and it will program,

Gadjet i havent got anuno here but try what i typed above and see if it works

and can you please post back if it worked or not

Regards
Dazz
Attachments
arduino mega.rar
(299 Bytes) Downloaded 1305 times
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
DavidA
Matrix Staff
Posts: 1075
Joined: Fri Apr 23, 2010 2:18 pm
Location: Matrix Multimedia Ltd
Has thanked: 58 times
Been thanked: 258 times
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by DavidA »

This is a X-post from another thread but i think it might be useful here too:

Hello Guys,

Just to point out we have released an FAQ with a fix and some guidelines for getting your Arduino running with Flowcode via the USB bootloader.

We are hoping in a future patch/fix to provide a simpler solution (one with less effort!) via a series of edits to the FCDs and some new batch files, but for the moment this guide should be able to get most people up and running.

http://www.matrixmultimedia.com/support ... f=68&t=797

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by dazz »

Hi DavidA
I can confirm the new files works on a Mega2560, big thanks to you guys for sorting this so quickly

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

yutronic
Posts: 18
Joined: Mon Jul 21, 2014 11:31 am
Has thanked: 10 times
Been thanked: 5 times
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by yutronic »

I have noticed that in Flowcode avr V5, Arduino Uno PDIP has many pins "Not connected" (PIN 3, 4, 5, 6...) while Duemilanove has them all connected. On the actual Uno board they are all connected the same way as on Duemilanove.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Using Arduino Hardware with Flowcode for AVR

Post by dazz »

Hi yutronic
the reason the chip view is like that is the arduino useable input/outputs are shown connected to their chip pins, the chip pins that appear unconnected in chip view are ones that are not able to be used as inputs or outputs, if you can see a mistake in the chip view please pm me and attach a diagram showing what pins are wrong and i will change the fcd file

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

Post Reply