3 Configuration Example

As shown in Figure 1-1, the crystal should be connected directly between the pins TOSC1 and TOSC2. Some devices might require additional external capacitors on these pins, as the internal oscillator characteristics can vary. Refer to the device datasheet for details on crystal connections. The oscillator is optimized for use with a 32.768kHz watch crystal, or an external clock signal in the interval of 0 - 256kHz. In this example, the eight LEDs in port B are used to display the value of the RTC. The LED on pin B0 will change state every second. The next six LEDs represent the minutes in binary, and the LED on pin B7 alternates every hour.

Some considerations must be taken into account when clocking the Timer/Counter from an asynchronous clock source. A 32.768kHz crystal has a stabilization time of up to one second after power-up. The controller should therefore not enter power-save mode less than one second after power-up. Care should also be taken when configuring the timer/counter to operate in asynchronous mode. See the device datasheet for detailed instructions. When updating the timer register, the data is transferred to a temporary register and latched after two external clock cycles. The Asynchronous Status Register (ASSR) contains status flags that can be checked to verify that the written register is updated.

The example code is written for Atmel START. It can be downloaded from the "BROWSE EXAMPLES" entry of Atmel START for both Atmel Studio 7 and IAR IDE. Double click the downloaded .atzip file and the project will be imported to Atmel Studio 7. To import the project in IAR, refer Atmel START in IAR, select "Atmel Start Output in External Tools" → "IAR".