// Display time function
void display_time(void) {
// Set digit select lines to display each digit in turn
for (unsigned char i = 0; i < 6; i++) {
// Turn off all digits
GPIO = 0b00000000;
// Set the appropriate digit high
GPIO = 1 << i;
// Output the appropriate segment pattern
GPIO = display_buffer[i];
// Delay for a short period to allow the display to update
__delay_us(100);
}
}
// Update time function
void update_time(void) {
// Check if timer0 has overflowed
if (TMR0IF) {
// Reset timer0 and set the appropriate flag
TMR0 = 6;
TMR0IF = 0;
// Increment seconds counter
seconds++;
// Check if seconds counter has reached 60
if (seconds == 60) {
// Reset seconds counter and increment minutes counter
seconds = 0;
minutes++;
// Check if minutes counter has reached 60
if (minutes == 60) {
// Reset minutes counter and increment hours counter
minutes = 0;
hours++;
// Check if hours counter has reached 24
if (hours
// Display time function
void display_time(void) {
// Set digit select lines to display each digit in turn
for (unsigned char i = 0; i < 6; i++) {
// Turn off all digits
GPIO = 0b00000000;
// Set the appropriate digit high
GPIO = 1 << i;
// Output the appropriate segment pattern
GPIO = display_buffer[i];
// Delay for a short period to allow the display to update
__delay_us(100);
}
}
// Update time function
void update_time(void) {
// Check if timer0 has overflowed
if (TMR0IF) {
// Reset timer0 and set the appropriate flag
TMR0 = 6;
TMR0IF = 0;
// Increment seconds counter
seconds++;
// Check if seconds counter has reached 60
if (seconds == 60) {
// Reset seconds counter and increment minutes counter
seconds = 0;
minutes++;
// Check if minutes counter has reached 60
if (minutes == 60) {
// Reset minutes counter and increment hours counter
minutes = 0;
hours++;
// Check if hours counter has reached 24
if (hours == 24) {
// Reset hours counter
hours = 0;
}
}
}