Change clock frequency in Flowcode to match Arduino hardware [Solved]

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
Ariko
Posts: 18
Joined: Tue Feb 23, 2016 10:28 pm
Has thanked: 6 times
Been thanked: 8 times

Change clock frequency in Flowcode to match Arduino hardware [Solved]

Post by Ariko »

I have a 3V 8Mhz Arduino Pro Micro clone that is fitted with an Atmega32u4 processor. The only Target option within flowcode that allows me to program the device is the ‘Arduino LilyPad Usb’. However, the LilyPad Usb target has the clock speed set to 16MHz by default with no ability to change it from within the General Options tab / Options menu.

By running a 1Hz flasher test program I confirmed a 2s ON time and 2s OFF time, which indicates Flowcode is set to 16Mhz and therefore the program is running at half speed.

I have attempted to change the clock frequency by inserting an OSCCON statement into a C Code block at the start of the 1Hz flasher program but this flags an OSCCON undeclared error when compiling.

I have also tried using the ‘Arduino Micro 8MHz’ target but this will not compile to my Arduino Pro Micro clone.

Searching the forum posts has not provided an answer, therefore I wonder if some kind soul can point me in the right direction, by advising how to set the clock frequency in Flowcode for a clone Arduino device running on an 8MHz external crystal oscillator?

Thanks in advance.
Last edited by Ariko on Sun Sep 17, 2023 8:37 pm, edited 1 time in total.

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: Change clock frequency in Flowcode to match Arduino hardware

Post by mnf »

As a temporary fix you can edit the definition file.

Assuming you are using v8 - it is in
C:\ProgramData\MatrixTSL\FlowcodeV8\FCD\ARD

Make a backup copy of Arduino Lilypad Usb.fcdx

Then edit it (the original) (notepad, notepad++) - and change
<clock max_speed="16000000"
master_divider="1"
fixed="16000000" />
to

<clock max_speed="16000000"
master_divider="1"
default="8000000" />
There is also a 'default' copy of the fcdx file (in C:\Program Files (x86)\Flowcode v8\DefaultData\FlowcodeV8\FCD) - but try on the 'live' version first.

Note if you use notepad to edit it likes to save with a .txt extension (which you don't want)

Martin

chipfryer27
Valued Contributor
Valued Contributor
Posts: 774
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 185 times
Been thanked: 204 times

Re: Change clock frequency in Flowcode to match Arduino hardware

Post by chipfryer27 »

Hi

Just to follow up on Martin's (as always) excellent advice, Notepad++ is a free download and I would strongly recommend you use that to edit the file. Other text editors that are not designed for "code" can often cause no end of frustration.

Regards

Ariko
Posts: 18
Joined: Tue Feb 23, 2016 10:28 pm
Has thanked: 6 times
Been thanked: 8 times

Re: Change clock frequency in Flowcode to match Arduino hardware [Solved]

Post by Ariko »

Hi Martin & chipfryer27, thank you both. That did it!! :D

I amended the live version in C:\ProgramData\MatrixTSL\FlowcodeV8\FCD\ARD using Notepad++ as recommended. Not only do I now have the 8MHz clock setting available under the General Options tab / Options menu but other variations too. Bonus!

I am still on V8 for now as I have two long term projects nearing completion and would rather not switch to V10 until they are done.

Much appreciated. You have saved me hours, I am sure.

Kind regards

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: Change clock frequency in Flowcode to match Arduino hardware [Solved]

Post by mnf »

Glad to hear it worked okay..

There are many good changes in v10 - so it's maybe worth talking a peek if time allows...

Martin

Post Reply