Programming unit for AVR ATMEGA328P-AU
Moderator: Benj
Programming unit for AVR ATMEGA328P-AU
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
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
-
- 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
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.
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
Re: Programming unit for AVR ATMEGA328P-AU
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)
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)
-
- 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
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
Can you set the clock speed in the program options as 1mhz?
Martin
Re: Programming unit for AVR ATMEGA328P-AU
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?
-
- 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
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
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
Re: Programming unit for AVR ATMEGA328P-AU
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.
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.
Re: Programming unit for AVR ATMEGA328P-AU
Where can I find the FC batch file? If I could change it for my FTDI232 this would be the best.
-
- 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
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
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
-
- 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
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
@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
Re: Programming unit for AVR ATMEGA328P-AU
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
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
-
- 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
Look like it uses the usb_tiny programmer by default (uses avrc_usb_tiny.bat) (see the programmer tab of compiler options)
Martin
Martin
- 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
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
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
Re: Programming unit for AVR ATMEGA328P-AU
Wow, that also sounds like a super simple solution, I will try it tonight.
Thanks a lot!
Greetings Chris
Thanks a lot!
Greetings Chris
Re: Programming unit for AVR ATMEGA328P-AU
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...
so for me, despite the changes, I cannot change the clock frequency when I select the Nano. It is always fixed at 16 MHz...
- 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
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
C:\ProgramData\MatrixTSL\FlowcodeV8\FCD\ARD
Then change project target to "Arduino Nano 328AU"
btw. C:\ProgramData is a hidden directory
-
- 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
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.
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
Re: Programming unit for AVR ATMEGA328P-AU
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?
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?
- 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
If you select the Arduino Nano 328AU I posted as the target, you can then use an analog component and select An6