32.768kHz Crystal

A project log for DIY Body Scale

Fixing a broken scale with DIY hardware

BenjaminBenjamin 11/23/2016 at 16:270 Comments

The Atmega 8 can't do an interrupt through the WDT module. It only can do a direct reset of the whole CPU. So this way to wake up the CPU from the sleep isn't practicable. Another way is to run the timer with an external clock in the sleep mode and generate an interrupt through this. I use a 32.768kHz crystal for this job.

Activated the Asynchronous mode of Timer2

ASSR |= (1<<AS2);
TCNT2 = 0x00;
OCR2 = 32;
TCCR2 = (1<<CS20);

And it seems to work!