I am looking for a bootloader For Mega2560 for 12 MHZ crystal. (all boatloader is for 16 mHZ only)
Using prescaler 8, I can get a 3KHz PWM on the pins,
16 MHZ crystal give 4KHZ PWM on the pins,
I have tried to replace the crystal after burning my project to the MEga2560 and give me 3khz PWM, but wont allow me to load another program. So I return again the 16 MHZ crystal so I can upload another program.
thanks in advance
Does it really have to be 3000 Hz ? Is that for 8-bit PWM ?
The bootloader takes care of uploading a sketch, and the bootloader has to know the cpu clock as well.
You could use a programmer and the ICSP header to upload a sketch, or make a bootloader for 12MHz with Optiboot.
If you are going to use the ATmega2560 at 12MHz, a new definition can be added to the "boards.txt" file. Copy the settings from the normal Mega board, and give it a new name with 12MHz as clock.
thanks for the reply
My goal is to the make the Mega2560 flashable by USB with 12 Mhz crystal (that will create 3khz PWM)
Uploading the hex file using USB makes things simpler if you updating the program for revision in the future (with laptop only)
I need to edit the bootloader file to make it respond to 12MHZ crystal
I am not so familiar with this things
Where do I get the bootloader file and which parts need to be edited?
And of course need need to compiles again to Hex file to be uploaded by ISP
I dont see much guide how to do this?
Creating a bootloader and creating a new definition in boards.txt is not easy to do.
Are you sure you need 3000Hz ? Can you tell us what it is needed for ?
Optiboot : GitHub - Optiboot/optiboot: Small and Fast Bootloader for Arduino and other Atmel AVR chips
I don't see the Mega 2560 with the default bootloaders.
To burn the bootloader, use the command from the Arduino IDE menu. That sets also the fuses.
Perhaps it is possible to keep the 16MHz bootloader ?
The section for the Mega 2560 in boards.txt contains:
The "mega.build" is what the compiler uses to compile a sketch.
The "upload.speed" is the baudrate to upload a sketch via the bootloader.
With the 16MHz bootloader at 12MHz, the baudrate will become 86400.
Perhaps you can use that as upload speed. It is not a standard baudrate, I doubt if it will work.
I am trying to build a PWM generator to test drive IGBT module.
The original unit drives the IGBT with 3Khz PWM to produce sinewave from 60HZ or lower
I am building test rig to test frequency converter drive output.
at the moment, I am using ISP to download the program, but its better if I can use USB
I have tried to replace the 16 MHZ crystal with 12 MHZ and give me 3KHZ PWM
Original Optiboot doesn't support Atmega2560.
You could check my fork as it have support for it, here: GitHub - majekw/optiboot at supermaster
Then it should be enough to change AVR_FREQ to 12000000L and compile things.
You'll also need Avrdude 6.1 or newer to work properly with this bootloader (Arduino is shipped with older version and you'll have problems with accessing all flash).