4 Copyright Luki <humbell@ethz.ch>
5 Copyright 2011 Michel Pollet <buserror@gmail.com>
7 This file is part of simavr.
9 simavr is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 simavr is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with simavr. If not, see <http://www.gnu.org/licenses/>.
24 #define F_CPU 10000000
27 #include <avr/interrupt.h>
28 #include <util/delay.h>
29 #include <avr/sleep.h>
34 //#include "avr_defines.h"
36 #include "avr_mcu_section.h"
37 AVR_MCU(F_CPU, "atmega48");
39 static uint8_t subsecct = 0;
40 static uint8_t hour = 0;
41 static uint8_t minute = 0;
42 static uint8_t second = 0;
43 static volatile uint8_t update_needed = 0;
45 #include "avr_hd44780.c"
49 /* External interrupt on pin D2 */
74 hd44780_outcmd(HD44780_CLR);
75 hd44780_wait_ready(1); // long wait
78 * Entry mode: auto-increment address counter, no display shift in
81 hd44780_outcmd(HD44780_ENTMODE(1, 0));
82 hd44780_wait_ready(0);
85 * Enable display, activate non-blinking cursor.
87 hd44780_outcmd(HD44780_DISPCTL(1, 1, 0));
88 hd44780_wait_ready(0);
96 while (!update_needed)
101 hd44780_outcmd(HD44780_CLR);
102 hd44780_wait_ready(1); // long wait
103 hd44780_outcmd(HD44780_DDADDR(4));
104 hd44780_wait_ready(0);
105 sprintf(buffer, "%2d:%02d:%02d", hour, minute, second);
109 hd44780_outdata(*s++);
110 hd44780_wait_ready(0);