selecting the external high frequency crystal

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I know that I need an external high frequency crystal with 64ms startup, but I don't know what size to select. 1k CK,
258 CK,
or 16k CK.

I have a 12mhz crystal. I was told if I select the wrong clock I may lock my chip. What exactly does the size refer to?

THX..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This has nothing to do with AVRstudio 4 forum. I suggest moving it to the AVRforum.

Which AVR chip are you using? There are differences in some AVR chips that make knowing which one very important.

ATMEL has an application note that covers external crystals (AVR042: AVR Hardware Design Considerations):

http://www.atmel.com/dyn/resourc...

BTW, do not confuse an external crystal with an external oscillator. The external crystal connects to the two XTAL 1 and 2 pins, while the external oscillator has its own power connections and only connects to the XTAL1 pin. If you get this clock fuse setting wrong it can get messy trying to change the clock fuse bits back.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thx for the reply, I don't see how to move a topic. Unless you mean to repost it there?

Just to answer the questions.

Quote:
Which AVR chip are you using? There are differences in some AVR chips that make knowing which one very important.
- The burner I bought says "avr studio 4" on it, and I must select "stk500 or avrisp" to communicate properly.

the Kit I bought says this

Quote:

Here we are giving you a quick start of using this ISP. More information can be found on the Atmel's help file AVRISP.chm available from the AVR Studio.
Please be advised that the Atmel's help file refers to the AVRISP RS232 version while our USB AVRISP uses the USB port. You will install the Virtual
Serial Port Driver. Because of the Virtual Serial Port Driver, your PC treats the AVRISP as a serial device. You can see the "CP210x USB to UART Bridge
Controller" under Windows Device Manager > Ports

As you can tell I'm new to this, possibly I'm not explaining my self well.

this is my target circuit http://www.raphnet.net/electroni...

here are my settings.

http://spawnlinux.dyndns.org/tmp...
http://spawnlinux.dyndns.org/tmp...

I'm just not sure about the second set.

I made a test chip with a blinking led work fine but it used the int clock. This is my first external attempt.

If this is the wrong place to post, would an admin be so kind to move my post for me?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I also was hoping a moderator might see it and move the post. At first I thought you were possibly designing and building an AVR circuit board. Now that the topic has changed from external crystal to using AVRstudio it turns out it really is in the correct forum after all :wink:.

From the schematic, your AVR processor is an ATmega8.

Here are some good ATMEL web sites for the AVR:
http://www.atmel.com/
http://www.atmel.com/dyn/product...
http://www.atmel.com/dyn/product...
http://www.atmel.com/dyn/product...

The ATmega8 data sheet is located at this link:
http://www.atmel.com/dyn/resourc...

The crystal oscillator information starts on page 27 of the data sheet.

The web site your schematic is from gives this: fuse settings for this project as: high_byte=0xc9 low_byte=0x9f. Page 223 of the data sheet is where the fuse bytes are explained.

high_byte=0xc9 is 11001001 in binary. Since AVR fuses are only programmed when set to zero, using table 87:
1 = RSTDISBL (un-programmed)
1 = WDTON (un-programmed)
0 = SPIEN (programmed)
0 = CKOPT (programmed)
1 = EESAVE (un-programmed)
0 = BOOTSZ1 (programmed)
0 = BOOTSZ0 (programmed)
1 = BOOTRST (un-programmed)

According to the table 87 default values, the only thing you have to change on a new AVR ATmega8 is to set CKOPT to 0 (programmed).

low_byte=0x9f is 10011111 in binary (Google or another search engine can help you with the hex base 16 to binary base 2 conversions.
1 = BODLEVEL (un-programmed)
0 = BODEN (programmed)
0 = SUT1 (programmed)
1 = SUT0 (un-programmed)
1 = CKSEL3 (un-programmed)
1 = CKSEL2 (un-programmed)
1 = CKSEL1 (un-programmed)
1 = CKSEL0 (un-programmed)

Tables 4 and 5 starting on page 27 shows you what the low fuse byte SUT1, SUT0, CKSEL3 through CKSEL0 bits do to enable the correct crystal oscillator setting. The table 88 low fuse byte defaults have more bit differences than the high fuse byte did. AVRstudio will typically "program" a fuse bit by checking the box next to the actual fuse name (it does not have to appear in the same order as the data sheet). By removing the check you "un-program" the fuse bit. After you setup all the fuse check boxes then you program the fuses. This is where you need to have the correct fuse settings and the AVR sill switch from its internal RC oscillator to its external crystal oscillator.

The ISP programming processes requires the AVR must have a functioning clock in order to be programmed. If you accidentally program the wrong clock (figure 10 on page 25 shows the other clock types), then there will not be any running clock, so you can no longer ISP program the AVR. If you mess up, the AVRfreaks board can explain how to recover, but it may require a soldering iron and external clock generator.

The other step is to setup AVRstudio with GCC to compile the source code. GCC is located here and has to be installed in AVRstudio:
http://sourceforge.net/projects/...
http://sourceforge.net/project/s...

BTW, all the AVRstudio stuff must run under Windows (see the AVRstudio help).

In order to check your settings you need to scroll over sideways in the fuses window, so you can see the actual bit name from tables 87 and 88.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, that was quite informational. The last guy on here a few months a go didn know what was meant my low and high bytes, I'm so thankful of your post.

ok so according to my screen shot

http://spawnlinux.dyndns.org/tmp...

I need the CKOPT check as you stated
my brown out to vcc=2.7
my BODEM to unchecked
and my clock is [cksel=1111 sut=01] third up from bottom.

Thanx so much!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No actually BODEN = 0 (programmed). Using your image:
http://spawnlinux.dyndns.org/tmp...

when you see this:
Brown-out detection enabled; [BODEN = 0]

You must check the box to make BODEN = 0. Otherwise, BODEN = 1 is set when the fuse is not checked. If you look at the fuse entries, you will see there is no setting that has BODEN = 1. This is implied by not checking the fuse as just described.

In contrast the BODLEVEL = 1 (un-programmed). There are two different settings:
Brown-out detection level at Vcc=4.0 V [BODLEVEL = 0]
Brown-out detection level at Vcc=2.7 V [BODLEVEL = 1]

The correct BODLEVEL = 1 is selected in your screen shot. This is because you know from the low byte that BODLEVEL should equal 1, so the fuse with [BODLEVEL = 1] is checked.

Sometimes there is a single fuse to check, other times there are more than one fuse to choose from. The correct fuse to check is the one where the fuse value matches what your web page said to use. The data sheet shows you how to decode the web page fuse bytes into the actual fuse values, so you know what to set in AVR studio.

The dangerous one was the crystal setting which you correctly identified where you circled SUT = 01. If you got the BODEN wrong the first time, you can still correct this without any problem.