Page 1 of 1

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

Posted: Sat Sep 16, 2023 11:55 pm
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.

Re: Change clock frequency in Flowcode to match Arduino hardware

Posted: Sun Sep 17, 2023 8:28 am
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

Re: Change clock frequency in Flowcode to match Arduino hardware

Posted: Sun Sep 17, 2023 9:43 am
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

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

Posted: Sun Sep 17, 2023 8:26 pm
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

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

Posted: Mon Sep 18, 2023 1:25 pm
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