Pages: [1]   Go Down
Author Topic: Oscillator/Crystal requirements ...  (Read 885 times)
0 Members and 1 Guest are viewing this topic.
Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For testing stand alone projects, I often build a minimalist setup on a breadboard with a 328P with an Uno configured as an ISP programmer.  And I always deviate from the instructions because otherwise things just don't work.  And this is where you guys come in.

The minimalist setup is just the 328P on a breadboard, no external clock.  However, I have never been able to make that work.  I've made sure everything is wired up correctly, the only thing missing is the crystal and caps.  However, whenever I try to burn the bootloader provided for that setup, the IDE fails telling me it's not the right chip, recheck connections or use -F to bypass check.  NOTE: Yes, I am specifically picking the bootloader that you download from that page, it's listed as 'ATmega328 on a breadboard (8 MHz internal clock)' in the IDE.

However, as soon as I add a crystal circuit, or just an oscillator, everything works like a charm.  Bootloader burns and sketches run.  I can even remove the external clock after burning the bootloader and it continues to work as expected.  HOWEVER, if I tried to re-burn the bootloader, it will fail again and I have to add the external clock back in.  I have tried this both with DIP as well as TQFP packages, same results.  It refuses to burn the bootloader till there's a crystal in the circuit.  (side note: soldering tiny wires on a TQFP for the external oscillator is a P.I.T.A.!!)

Has anyone else experienced this?  Technically, and according to the instructions, one should be able to burn that bootloader without any external components, yet I'll be damned if I can get that to work.  I get all of my ICs from Mouser or Digikey (I suspect a lot of you are doing the same.)

So, what's going on?
Logged

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


http://arduino.cc/forum/index.php?topic=59972.0
Logged

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The high_fuses setting isn't even 0xD9 to begin with.  I just verified with the download from that page, just in case I had changed it already.  The downloaded file has the high_fuses setting at 0xDA (not 0xD9 as you indicated.)

So I should change that regardless, to the 0xD8 you say ...  I shall try that and see what happens.

For posterity, this is what the boards.txt file looks like freshly downloaded:
##############################################################

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=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino: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
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 58
Posts: 3988
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As shipped the ATmegas have the internal oscillator running near 8 MHz but the CPU clock runs 1 MHz, just in case that makes a difference. Oscillator is pre-scaled by a divider default set = 8.

Logged

Examples can be found in your IDE.

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16464
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Has anyone else experienced this?  Technically, and according to the instructions, one should be able to burn that bootloader without any external components, yet I'll be damned if I can get that to work.  I get all of my ICs from Mouser or Digikey (I suspect a lot of you are doing the same.)

So, what's going on?

Once the fuses have been set to use external crystal you cannot program the chip with ICSP without using an external crystal unless you first change the fuse settings to utilize the internal clock. I think everything is working correctly for you, just that you are getting out of sequence of steps you have to perform.

That make sense?


Lefty
Logged

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That would make sense Lefty, however why wouldn't it have worked in the first place, when I just got them and without having done anything to them yet.  I haven't tried changing the high_fuses setting yet, but I will as soon as I get home.

Also, Lefty, if I burned the breadboard bootloader which sets the thing to run with its internal clock, why does it need the external connected when re-burning? Unless it has to do with the wrong value in the boards.txt again ...
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
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

The internal clock isn't accurate enough to work with serial comms unless you calibrate it. If you need serial comms, don't use the internal clock, use a crystal or resonator. If you don't need serial comms, you can use the internal clock, but don't use the bootloader either (it uses serial comms) - just program your sketch directly into the microcontroller via ICSP. This frees up pins 0 and 1 for general I/O as well as the clock pins.
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.

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16464
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Also, Lefty, if I burned the breadboard bootloader which sets the thing to run with its internal clock, why does it need the external connected when re-burning? Unless it has to do with the wrong value in the boards.txt again ...

Could be, parts of the IDE bootloading burning is still a mystery to me, the sequence of operations for sure. What I have done is build a small programming board with a 28 pin ZIP socket on which I've wired the basic power, bypass caps, pull-up on reset, a simple 3 terminal 16mhz ceramic resonator, and finally the 6 pin male ICSP pins. Then I just plug my USBtiny programmers ISCP cable to the small programming board and burn away either from the IDE or directly from AVRDUDE using a windows GUI front end for AVRDUDE. Works great and with the resonator wired the chip will program no matter if it's existing fuses are set for external clock or internal clock as shipped from the factory.



Lefty
Logged

Pages: [1]   Go Up
Jump to: