Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include "lcd.h"
- #include <avr/interrupt.h>
- static uint8_t ts = 0, tm = 0, th = 0, tSS = 0;
- void gettime()
- {
- char time[9];
- time[0] = '0' + (th / 10);
- time[1] = '0' + (th % 10);
- time[2] = ':';
- time[3] = '0' + (tm / 10);
- time[4] = '0' + (tm % 10);
- time[5] = ':';
- time[6] = '0' + (ts / 10);
- time[7] = '0' + (ts % 10);
- time[8] = '\0';
- lcd_clrscr();
- lcd_gotoxy(4, 0);
- lcd_puts(time);
- }
- ISR(TIMER0_COMP_vect)
- {
- tSS++;
- if (tSS == 100) {
- tSS = 0;
- ts++;
- if (ts == 60) {
- ts = 0;
- tm++;
- }
- if (tm == 60) {
- tm = 0;
- th++;
- }
- if (th == 24) {
- th = 0;
- }
- gettime();
- }
- }
- int main(void)
- {
- DDRD = _BV(4);
- TCCR1A = _BV(COM1B1) | _BV(COM1B0) | _BV(WGM10);
- TCCR1B = _BV(WGM12) | _BV(CS11);
- OCR1B = 250;
- TCCR0 = _BV(WGM01) | _BV(CS00) | _BV(CS02);
- OCR0 = 71;
- TIMSK = _BV(OCIE0);
- sei();
- lcd_init(LCD_DISP_ON);
- lcd_clrscr();
- while (1)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement