Warning to KiCad Users: Avoid all links to kicad - pcb.org – Use kicad.org

Starting Electronics needs your help! Please make a donation to help cover our hosting and other costs. Click the donate button to send a donation of any amount.

Donations Received:

ATtiny2313 System Clock Selection

Created on: 25 April 2013

Part 7 of the ATtiny2313 Tutorial

The system clock for the ATtiny2313 can be selected from a number of different sources: from an external clock source, internal 4MHz RC oscillator, internal 8MHz RC Oscillator, watchdog internal 128kHz oscillator or an external crystal / ceramic resonator.

Selecting the Clock Source

The clock source can be selected by programming fuse bits in the microcontroller so that the desired clock source will be used by the microcontroller at startup.

Atmel Studio can be used to program the clock source selection bits. There is also a fuse bit that can be programmed in order to divide the clock source by 8 – the CKDIV8 fuse bit.

The system clock can be output on pin 6 of the ATtiny2313 by setting the CKOUT fuse bit.

CKOUT pin on the ATtiny2313 microcontroller

This video shows the CKOUT bit being set so that the system clock can be viewed on an oscilloscope. Various system clock sources are then selected by setting the appropriate fuse bits using Atmel Studio.

Can't see the video? View on YouTube →

Default Clock Fuse Settings

The image below shows part of the Device Programming dialog box from Atmel Studio – the default clock settings can be seen.

ATtiny2313 default clock fuse settings

A new ATtiny2313 will have the default factory settings of the clock fuses set as follows:

  • CKOUT fuse bit unprogrammed – the system clock will not be available on pin 6
  • CKSEL fuse bits – set to use the internal 8MHz RC oscillator for the system clock
  • CKDIV8 fuse bit – set to divide the system clock by 8
  • SUT fuse bits – start-up time set to 14CK + 65 ms

This means that the system clock is set to 1MHz by default: 8MHz ÷ 8 = 1MHz.

Books that may interest you:

C Programming with Arduino Book Ultimate Arduino MEGA 2560 Hardware Manual Ultimage Arduino Uno Hardware Manual

← Go back to Part 6Go to Part 8 →