Pages: [1] 2   Go Down
Author Topic: atmega328 on a Breadboard (8MHz internal clock)  (Read 4604 times)
0 Members and 1 Guest are viewing this topic.
California
Offline Offline
Sr. Member
****
Karma: 3
Posts: 444
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've bootloaded my atmega328P with the "atmega328 on a Breadboard (8MHz internal clock)" bootloader but when i try to upload a sketch I get the error:
Code:
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

I'm using the AVR Pocket Programmer from sparkfun and I know it works because the atmega328p wasnt working before I reburnt the UNO bootloader onto it and now it works fine. But no luck with any other bootloader.

On a semi related note, does PWM work the same at 8MHz? I wanted to skip the external crystal because Im makeing a very simple fading LED device but obviously I may have to re-think it if PWM isn't effective at 8MHz.

ALSO the program isn't terribly time sensitive so accuracy isn't an issue, but does my sketch have to be changed to account for the clock speed change or is that accounted for by the bootloader so that millis() and delay() still act mostly the same?

Thanks!
Logged

0
Offline Offline
Shannon Member
****
Karma: 218
Posts: 12583
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For sketch loading the serial baud rate has to be right  - if the internal clock isn't accurate enough this could be an issue??
Logged

[ I won't respond to messages, use the forum please ]

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13042
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've bootloaded my atmega328P with the "atmega328 on a Breadboard (8MHz internal clock)" bootloader but when i try to upload a sketch I get the error:

Did you use the IDE to burn the bootloader or did you do it through the command-line?

Quote
On a semi related note, does PWM work the same at 8MHz?

No.  It runs at half the frequency.  For most applications, you will not notice a difference.

Quote
I wanted to skip the external crystal because Im makeing a very simple fading LED device but obviously I may have to re-think it if PWM isn't effective at 8MHz.

For fading LEDs, you will not notice a difference.

Quote
ALSO the program isn't terribly time sensitive so accuracy isn't an issue, but does my sketch have to be changed to account for the clock speed change

So long as the entry in "boards.txt" is correct, you only need to build your Sketch.
Logged

California
Offline Offline
Sr. Member
****
Karma: 3
Posts: 444
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I used the IDE. Is that a mistake? I'm not currently around my computer.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13042
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I used the IDE. Is that a mistake?

No.  That's a good choice.  The IDE takes care of the fuses and the bootloader.

But it also means the fuses are very likely correct so something else must be wrong.
Logged

California
Offline Offline
Sr. Member
****
Karma: 3
Posts: 444
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Could it be that I'm using the 328p and not the 328?

Also I'm using the UNO and the UNO bootloader is the only one that works. Does that mean anything?
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13042
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Are these the instructions you used...
http://arduino.cc/en/Tutorial/ArduinoToBreadboard

Was this the "boards.txt" you used...
http://arduino.cc/en/uploads/Tutorial/breadboard.zip

If "yes" to both questions, then the fuse settings are wrong.  Open the "boards.txt" file and change this line...

  atmega328bb.bootloader.high_fuses=0xD9

...to this...

  atmega328bb.bootloader.high_fuses=0xD8
Logged

Scotland
Offline Offline
Edison Member
*
Karma: 26
Posts: 1343
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This is what I use :

Code:
atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=stk500
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xD8
atmega328bb.bootloader.extended_fuses=0x07
atmega328bb.bootloader.path=atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_ATMEGA328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino


Hope that helps.


Drew
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I had the same problem the only difference is that I am using the duemilanove to burn the bootloader and upload the sketches. After reading this thread I finally figured out my problem. For the ATmega328p spycatcher2k's txt worked after putting it into the right location. His txt needs to be appended to the \arduino-00xx\hardware\arduino\boards.txt. The arduino IDE MUST be restarted each time you edit the board.txt. I had used his settings before however never knew that the IDE needs a restart before changes take effect. Only when I fat fingered Coding Badly's fuse edit to read 0xD98 did i realize that the board file is only read when the IDE starts. No matter how many times I edited the boards file to fix my mistake until I restarted the IDE the changes would not take effect.  Hope this helps someone avoid my mistakes of the last 12 hours.
Logged

Gloucester
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Could this be why I too get the dreaded
"avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51 Pro Mini"
when using the "Pro Mini (3.3V, 8 MHz) w/ ATmega328" with a mega328P chip fitted?

Yours
Simon M.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 173
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I used the IDE. Is that a mistake?

No.  That's a good choice.  The IDE takes care of the fuses and the bootloader.

But it also means the fuses are very likely correct so something else must be wrong.


I need to "re-bootload" some 328Ps that I bought, which are configured to run at 16Mhz/5V.

I need to change the bootloader so I can run the 328s at 8Mhz/3.3v.
Is there a "clear" procedure on how to do this?
Where do I get the modified bootloader from?

thanks
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you actually want to install a bootloader on those chips (in which case you'll need to have some sort of serial interface in order to use it), or do you just want to load a program on to them? Or, do you already have the program loaded, and you just want to change them to run at 8MHz using the internal clock?
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

0
Offline Offline
Full Member
***
Karma: 0
Posts: 173
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you actually want to install a bootloader on those chips (in which case you'll need to have some sort of serial interface in order to use it), or do you just want to load a program on to them? Or, do you already have the program loaded, and you just want to change them to run at 8MHz using the internal clock?


I bought a handful of these when they were on sale
http://www.spikenzielabs.com/Catalog/index.php?main_page=product_info&products_id=160


I was told that I need to re-program the bootloader so the 328's will run at 8Mhz. I will be running these @ 3.3V in order to match the
logic levels of the hardware I'm interfacing with. The 328 data sheet shows that 16Mhz @ 3.3V is not in "the safe zone", so I'm choosing
to lower the clock to 8Mhz. For my application, speed isn't terribly important.

Obviously, I need to replace the 16MHZ crystal with an 8Mhz crystal, that is no problem.

Thanks
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13042
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


The bootloader will very likely work at half the clock speed.  The latest optiboot does.  Try halving the baud rate entry in the boards.txt file.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to use an atmega 328 with 8MHz internal clock with an IR LED that triggers a camera shutter. I have uploaded the sketch but it does not trigger the shutter. It works on my UNO. Could this be caused by the lower clock speed?

Thanks
Logged

Pages: [1] 2   Go Up
Jump to: