I have a value that is not getting updated. Please see near line 142 of RTC.c. The variable in question is called julian_date. At first I didn't understand why my addition result was coming out wrong, so I added some code to visually inspect the value in real time on the LCD. What I saw was different when I don't use the code on line 145.
Line 145 is essential to getting julian_date to update correctly, but is JUNK code. If I don't include it, the value of julian_date is not correct. This sprinti function doesn't do any displaying (I took that code out), so I really don't need it, but can't get rid of it.
The following code is shows what I am doing. It's very simple, so I don't understand why julian_date is getting optimized out or something. I use the value, so it should not be optimized out, but it obviously is.
The Excel spreadsheet is just FYI for anybody trying to find the Day of Week, or the Julian Date. It took me a while to find a good algorithm that will work from 2001 to 2099. Don't trust Wikipedia without verifying the formulas. None of them worked, so I had to work out my own.
Thank you, Richard V
Code: Select all
// Find Julian Date. Find month day 1 julian date first, less 1.
day = 18; // The date
julian_date = Monarray_LPY[month]; // Leap year index
julian_date += day; // Add day of month to form true Julian Date
// This Dummy line is needed or value of julian date does not come out correctly.
sprintf(Msg, "Dummy line: 0x%x ", julian_date); // If I don't leave this line here, julian_date is wrong. Why?
// julian_date is displayed later.