One feature of AVR devices that can baffle new users is the default clock setting on new AVR microcontrollers. They are set to run from their internal RC oscillator, usually 1 MHz, which throws out the timing on code samples, such as UART.
If the code is configured for an 8MHz clock and there is a 8MHz clock on the target board, you expect it to work but instead you get nothing or garbled characters. This is due to the default Internal RC. How do you change it?
All AVR programmers have a Fuse screen somewhere, that lists the configuration fuses for the AVR. These set how the device runs, including things like brown-out, reset vector, debug enables and clock.
The settings we are interested in are CLKSEL and CLKDIV8. The 4 CLKSEL bits (Clock Select) define the type of clock. If you read the fuses on a new AVR, they appear as an Internal RC Oscillator. The default speed depends on the particular AVR. Change this to an External Crystal/Ceramic Oscillitor for most circuits. If the CLKSEL fuses are displayed in binary, this is 1110 or 1111 for most target circuits. Do NOT choose External Clock (0000) unless you have a specialised clock circuit (not just crystal) on your board or you will lock yourself out of the AVR microcontroller.
Most devices default to 1MHz Internal RC but some, like ATtiny2313, default to 8MHz, but don’t be fooled as they also have a CLKDIV8 fuse that divides the clock by 8. This also needs to be unchecked if it is present on the device.
Program the new fuse settings and your AVR will now run at the speed you expect.