Pages: [1]   Go Down
Author Topic: Arduino Uno to program Mega328 with 8MHZ bootloader on breadboard?  (Read 1026 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 3
Posts: 277
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to run a mega328 at 3.3volts so I was looking at this tutorial
http://arduino.cc/en/Tutorial/ArduinoToBreadboard
and this tutorial
http://arduino.cc/en/Tutorial/ArduinoISP
to make it happen.  If I can get the bootloader onto the breadboarded mega328, will I be able to use an arduino uno (with the uC removed) to program the breadboarded mega328?
Logged

Arduino Uno;
Mega328

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3532
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes this is possible. The ArduinoISP sketch can be used to burn a bootloader onto the breadboarded chip. Personally I like to use the small FTDI breakout boards, but removing the µC from an Arduino should work too.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

0
Offline Offline
Sr. Member
****
Karma: 3
Posts: 277
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks.....I will give it a try!
Logged

Arduino Uno;
Mega328

California
Offline Offline
Sr. Member
****
Karma: 2
Posts: 433
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You could also just put it on the breadboard and connect the ground, reset, rx and tx to the arduino board that way you dont have to keep putting the chip in and out of the breadbard and arduino.

Also if you are doing anything time related you are still going to want to use a crystal and you'll need a bootloader meant for external 8mhz. If no time, then nevermind.
Logged

0
Offline Offline
Sr. Member
****
Karma: 3
Posts: 277
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could also just put it on the breadboard and connect the ground, reset, rx and tx to the arduino board that way you dont have to keep putting the chip in and out of the breadbard and arduino.

Also if you are doing anything time related you are still going to want to use a crystal and you'll need a bootloader meant for external 8mhz. If no time, then nevermind.

Is it safe to assume that anything involving the UART would be considered "time related"?  I was planning on using an 8MHZ external crystal for timing.  Is it a completely different bootloader that is needed or can I just modify the setting of the fuse bits in the boards.txt file in the hardware folder?  Couldn't I just compile the program as if I am using an arduino pro running at 3.3V and 8 MHZ and then program it through an old arduino board that still uses the FTDI chip (if using the FTDI chip versus the Atmega16U2 on the Uno even matters)?  I really don't understand how all of these parts on the arduino talk to each other. 
Logged

Arduino Uno;
Mega328

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3532
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The bootloader needs to be aware of the clock speed. As a result there are 16MHz bootloaders and 8MHz bootloaders (clock speed is a parameter when the bootloader is compiled). Burn the Arduino Pro 8MHz bootloader onto the chip and things should be fine, the UART can be used as normal, up to 57600 baud (115200 is too fast for 8MHz, need 16MHz for that.) Ditto for millis() etc., will work as expected, no adjustments needed on the programmer's part.

So yes, a different bootloader is needed, and the fuses need to be set for an 8MHz clock. The fuses actually set the hardware to operate a certain way, but the software (bootloader or your sketch) needs to be told how fast the hardware is running in order to get timing correct. (This is done via the F_CPU parameter.)
« Last Edit: December 15, 2012, 09:32:32 am by Jack Christensen » Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

0
Offline Offline
Sr. Member
****
Karma: 3
Posts: 277
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Excellent!  and thank you!  So my steps will be:

1.  Upload the ArduinoISP sketch onto an Arduino Uno following these instructions http://arduino.cc/en/Tutorial/ArduinoISP
2.  Connect the Arduino Uno to my new mega328 as shown in the bottom images of the above link
3.  In the arduino dev environment go to tools-->programmer and set it to "Arduino as ISP"
4.  In the arduino dev environment go to tools-->board and set it to "Arduino Pro or Pro Mini (3.3V, 8 MHZ) w Atmega 328
5.  In the arduino dev environment go to tools-->Burn Bootloader

So now I should have a mega 328 that I can run off of 3.3V reliably but that I could still program with 5 volts via the arduino uno with its mega328 removed.  Is this correct?  Will the Atmega16U2 on the Uno have any problem communicating and uploading sketches to a mega328 running an 8MHZ boot loader?
Logged

Arduino Uno;
Mega328

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3532
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think you've got it all figured out. The only thing I'm unsure about is the last question, I was wondering about that a little earlier. Give it a shot and let us know what happens!
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3532
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

FYI, uploading to an 8MHz ATmega328P works fine for me, using an Arduino Uno with an ATmega8u2 and the ATmega328P removed. The target chip on a breadboard has an 8MHz version of Optiboot, using an upload speed of 57600, and was powered by 5V from the Uno.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

0
Offline Offline
Sr. Member
****
Karma: 3
Posts: 277
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

FYI, uploading to an 8MHz ATmega328P works fine for me, using an Arduino Uno with an ATmega8u2 and the ATmega328P removed. The target chip on a breadboard has an 8MHz version of Optiboot, using an upload speed of 57600, and was powered by 5V from the Uno.

How do I set the upload speed to 57600 or is that all handled by the boot loader?
Logged

Arduino Uno;
Mega328

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3532
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How do I set the upload speed to 57600 or is that all handled by the boot loader?

It's in the boards.txt file. In the IDE, as long as you pick one of the 8MHz boards when burning the bootloader and then also the same one when uploading a sketch, you shouldn't have to set anything.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

0
Offline Offline
Sr. Member
****
Karma: 3
Posts: 277
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


It's in the boards.txt file. In the IDE, as long as you pick one of the 8MHz boards when burning the bootloader and then also the same one when uploading a sketch, you shouldn't have to set anything.

Awesome!  Can't wait to try it out!
Logged

Arduino Uno;
Mega328

Pages: [1]   Go Up
Jump to: