Programming unit for AVR ATMEGA328P-AU

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

Moderator: Benj

Post Reply
ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Programming unit for AVR ATMEGA328P-AU

Post by ChrisT66 »

Hello, I would like to program a 328P-AU If I select a Nano as target Flowcode will recognize my FTDI232 and burn the program. But the Nano runs with 16MHz. My AU runs at 1MHz and I cannot change the frequency for the Nano.
If I choose the right AVR atmega328p-au TQFP, there is no choice for the port of the FTDI and burning does not work. Do single chips have to be burned in Flowcode with a special programmer and if so why?

Thanks! Greeting Chris

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by medelec35 »

Hi Chris,
When you selct Nano, Uno etc the hardware requires a boot loader and a fixed frequency as there is a Crystal on board.
If you don't run at the crystal speed there there will be all sorts of issues.
The only way to set your own speed is to select the ATMEGA328P target device.
If you do that it will override the boot loader if using UNO or NANO etc so I don't recommend you doing that unless you only have the ATMEGA328P chip itself.
Once you do that the chip will no longer work if used on a NANO or UNO and you use Arduino IDE to program it.
This is because the boot loader has been overwritten.

I'm not a leading expert on this so could be corrected.
Martin

ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by ChrisT66 »

Hello, Martin,

yes i use a naked atmega328p processor. The bootloader is already on it. Now I want to load the program with flowcode.
If I have chosen the right processor (atmega328pTQFP) there is no more port selection in the project settings and Flowcode does not recognize the FTDI232 I use for programming.
If I select a Nano for this, I can program the processor. Only Flowcode thinks that the processor works with 16MHz, but for me it is 1MHz, so all timings are wrong calculated....

Translated with www.DeepL.com/Translator (free version)

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by mnf »

Hi Chris, can you use another Arduino as a programmer. See, for example, https://amoghdesai.com/technology/bootl ... no-as-isp/

Can you set the clock speed in the program options as 1mhz?

Martin

ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by ChrisT66 »

My problem is that in Flowcode there is no selection of programmer ports for this AVR. Therefore Flowcode does not recognize my USB to TTL adapter. But for Arduinos it does. The question is why?

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by mnf »

Okay, I follow..
A couple of ideas.
Compile to hex using flowcode then program using your programmer using a command line. Create a .bat file if you need to do it more than once!
Or - create a new batch file for FC using your programmer - this is a bit more involved - I'll have a go later when I have my computer rather than my phone! But basically, copy the programmer details from a working batch file to the current. This is a bit more involved, bit of you want to use this setup a lot would be worth the extra work.
It would be easier if FC had the programmer as a separate setting - it's probably a bit late, but I'll add it to the wish list for v9..

Martin

ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by ChrisT66 »

Yes, I could take the hex file and burn it outside FC, but then ask myself why I paid 75 Euro for the AVR library yesterday... really annoying!
The easiest way would be to change the clock frequency in the Arduino settings just like with the AVRs.

Or I could find out which programmer FC wants to use for the AVRs.

ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by ChrisT66 »

Where can I find the FC batch file? If I could change it for my FTDI232 this would be the best.

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by mnf »

Hi Chris,

Try C:\Program Files (x86)\Flowcode\Common\Compilers\avr\batchfiles unfortunately the 'browse' option on compiler options (programmer tab amongst others) doesn't work very well..

Always make a copy first (we've only fallen into that trap) - and if you have a working version for a different target then copy and paste... (If not setting verbose mode in the Arduino IDE and using that can help too)

Martin

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by mnf »

The current command will look something like:

@SET AVRDUDEcmd="%~dp0..\bin\avrdude.exe" -p %2 -P %DUDEPort% -c %Programmer% -U flash:w:%5

and you'll need to replace the right hand side with something like

avrdude -c ft232r_mod -p m328p -P ft0 -U flash:w:led.hex

So @SET AVRDUDEcmd="%~dp0..\bin\avrdude.exe" -c ft232r_mod -p %2 -P ft0 (or %DUDEPORT??) - U flash:w:%5 - Note bracketed item might replace ft0...

Sorry - I don't have anyway of testing this though - and it might take a bit of tinkering. Please share if you get it to work (or if you don't - and we'll try and 'help' some more...)

Martin

ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by ChrisT66 »

Good morning Martin,

thanks for the support! Then i will test it to change the batch file.
I am not sure which file FC wants to use for programming the ATMEGA328, think the avrc file...

When i have a result, i post it here

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by mnf »

Look like it uses the usb_tiny programmer by default (uses avrc_usb_tiny.bat) (see the programmer tab of compiler options)

Martin

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by LeighM »

If the "Arduino Nano 328" FCD works except for the wrong clock frequency,
you could try editing the FCD file and remove the text fixed="16000000"
That will allow you to change the clock in the project settings

If that works, then you could create your own custom FCD,
copy the FCD to a new filename e.g. "Arduino Nano 328AU.FCD"
then change <device file="Arduino Nano 328" to <device file="Arduino Nano 328AU"

Example attached
Attachments
Arduino Nano 328AU.fcdx
(14.73 KiB) Downloaded 137 times

ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by ChrisT66 »

Wow, that also sounds like a super simple solution, I will try it tonight.

Thanks a lot!

Greetings Chris

ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by ChrisT66 »

Hello, Leigh,

so for me, despite the changes, I cannot change the clock frequency when I select the Nano. It is always fixed at 16 MHz...

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by LeighM »

Did you drop the attached file into ...

C:\ProgramData\MatrixTSL\FlowcodeV8\FCD\ARD

Then change project target to "Arduino Nano 328AU"

btw. C:\ProgramData is a hidden directory

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by medelec35 »

I would like to add to Leigh's post.
After any changes that are made to fcdx, cal files or any replacement components.
If Flowcode is open when changes are made, you must always use the Reload button before the changes will take effect.
Martin

ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by ChrisT66 »

The tip with the directory was an important hint. I had put the file in the wrong Flowcode V8 directory, there is also an ARD folder etc.
Now it works great, thank you!

Probably I still have a problem, because I want to use the analogue input 6 of the TQFT version, which is not available on the normal Nano. Or would it have to run on the AU chip anyway?

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by LeighM »

If you select the Arduino Nano 328AU I posted as the target, you can then use an analog component and select An6

ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Re: Programming unit for AVR ATMEGA328P-AU

Post by ChrisT66 »

This is great news :)

Thanks again for the quick help!

Post Reply