Starting Electronics Needs Your Help!
It is that time of the year when we need to pay for web hosting and buy new components and equipment for new tutorials. You can help by making a donation. Contribute to this website by clicking the Donate button. The total will be updated once daily. (You may need to clear your browser cache to see the updates.)

Target Amount: $2000
Amount Raised: $840

Donations Received

Top Donor: C.C. $100


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.

← Go back to Part 6Go to Part 8 →