What is a clock? It’s a time keeping entity that increments at a constant rate. Szymon Dyja demonstrated how to keep the time using built in counters of the ATTtiny2313. Szymon’s simple design uses a 16×2 LCD with backlight and has an accuracy of 1 second / 48 hours.
The 16 bit counter of the AVR is set to overflow when a second had lapsed, how to do this? Since the project uses an 8MHz crystal the counter is incremented every 8MHz/1024 and thus since the counter is 16 bit it will overflow at ((2 ^ 16-1) – (8000000/1024)) = 57822.5 which corresponds to a second. When the 16 bit counters over flow an interrupt is asserted, this assertion signals that the specific time span had lapsed and that global time variable needs to be updated which will also trigger the LCD update routines. Entire project can be downloaded here. The next step would be to add a synchronizing function to the clock to correct any inconsistencies. Time through Ethernet?