From d866095fb395e468be7facfc636f2ee501398498 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Thu, 1 Aug 2019 03:37:39 -0500 Subject: Remove New_Second method as the interrupt ends up doing too much. Just set a flag that states an update is needed. --- main.c | 60 +++++++++++++----------------------------------------------- main.h | 9 +++------ 2 files changed, 16 insertions(+), 53 deletions(-) diff --git a/main.c b/main.c index 78d0f77..8343233 100755 --- a/main.c +++ b/main.c @@ -89,53 +89,17 @@ void main(void) { #ifdef VFD Vfd_Set_Brightness(3); //Max brightness 3 - minimum #endif - - while(1){ - - } -} -void New_Second() { - // Set time and date variables from DS3231 - //#ifdef DEBUG - // UART_send_string("Updating current date time from DS3231\r\n"); - //#endif - Update_Current_Date_Time(); - - // Read temp - //#ifdef DEBUG - // UART_send_string("Reading Alarms and Temperature"); - //#endif - Read_Alarms_Temp(); - - // Get Alarm Status - Get_Alarm_Status(); - - // Separate the int timedate variables into chars - //#ifdef DEBUG - // UART_send_string("Formatting chars"); - //#endif - format_DateTimeChars(); - - // Format temperature - //#ifdef DEBUG - // UART_send_string("Formating temperature"); - //#endif - format_Temperature(); - - // Determine day of the week from Calendar Date - //#ifdef DEBUG - // UART_send_string("Determining day of week"); - //#endif - getWeekDay(Get_DayOfWeek(year, month, date)); - - // Enter loop and update display if sec changes from DS3231 - if (sec_chg != sec) { - - update_Display(); - - // Set temp_sec to current sec from DS3231 - sec_chg = sec; + while (1) { + Update_Current_Date_Time(); + Read_Alarms_Temp(); + Get_Alarm_Status(); + format_DateTimeChars(); + format_Temperature(); + getWeekDay(Get_DayOfWeek(year, month, date)); + if (update) { + update_Display(); + } } #ifdef ADC @@ -349,6 +313,8 @@ void update_Display() { void __interrupt() isr(void) { if (INTF == 1) { INTF = 0; - New_Second(); + update = 1; + } else { + update = 0; } } \ No newline at end of file diff --git a/main.h b/main.h index ed84202..3429b15 100755 --- a/main.h +++ b/main.h @@ -7,9 +7,8 @@ unsigned int ldr = 0; #define brtlvl ldr/256 unsigned int brtlvl_chg = 0; -// Initialize for timerr interrupt value -unsigned int counter = 0; -unsigned int interrupts = 0; +// Update to 1 if RB0 interrupt occurs, otherwise 0 +unsigned int update = 0; // Initialize variables for date time and alarms unsigned int sec = 0; @@ -69,6 +68,4 @@ void getWeekDay(unsigned int); // Determine Alarm status from control registers void Get_Alarm_Status(void); -void update_Display(void); - -void New_Second(void); \ No newline at end of file +void update_Display(void); \ No newline at end of file -- cgit v1.2.3-54-g00ecf