35#include <avr/interrupt.h>
40#define UNITS_PER_SECOND 1000
46static volatile uint16_t milliseconds = 0;
47static volatile uint8_t seconds = 0;
48static volatile uint8_t minutes = 31;
49static volatile uint8_t hours = 22;
51static char msg[9] = {0};
59 if (milliseconds < 999)
112 OCR0A = (F_CPU / PRESCALER / UNITS_PER_SECOND);
113 TCCR0A |= (1 << WGM01);
114 TCCR0B |= (1 << CS00) | (1 << CS01);
115 TIMSK0 |= (1 << OCIE0A);
124void set_time(uint8_t hrs, uint8_t mins, uint8_t secs)
141 msg[0] =
'0' + (hours / 10);
142 msg[1] =
'0' + (hours % 10);
147 msg[3] =
'0' + (minutes / 10);
148 msg[4] =
'0' + (minutes % 10);
153 msg[6] =
'0' + (seconds / 10);
154 msg[7] =
'0' + (seconds % 10);
char * get_time(void)
Getter function for time variables.
void set_time(uint8_t hrs, uint8_t mins, uint8_t secs)
Setter function for time variables.
void init_timer_counter_0(void)
Initialisation routine for 8-bit timer 0.
ISR(TIMER0_COMPA_vect)
Interrupt Service Routine.
Driver to provide setup and configuration of the timer/counter hardware on the ATmega328P.