Hi!
In short, I have created a date and time function with a clock yyyy/mm/dd and a 24h clock. I testing the whole function (With zero expectation for the system to work, but it did). What I mean with work is that the system is perfectly counting up every second. I assume it has to do with the systick or some timer? Is it by default 1 second?
EDIT: Forgot to add the code:
void UpdateTime(){
int days = 0;
passedTime += 1 * simulationSpeed; //Simulation speed can be ignored, lets say its 1.
totalSeconds = passedTime + dateSeconds + (dateMinutes60) + (dateHours3600);
int totalSecondsInDay = 86400;
seconds = totalSeconds%60;
minutes = (totalSeconds/60)%60;
hours = (totalSeconds/3600)%24;
//86400s in one day
if(totalSeconds >= totalSecondsInDay){ //new dateDay
dateSeconds = 0;
dateMinutes = 0;
dateHours = 0;
dateDay++;
passedTime = 0;
dayCounters++;
days = CalculateMonth(dateMonth, dateYear); //Returns nr of days in different months.
if(dateDay > days){
dateDay = 1;
dateMonth++;
if(dateMonth > 12){
dateSeconds = 0;
dateMinutes = 0;
dateHours = 0;
dateYear++;
dateMonth = 1;
ResetTime(); //Simply resets the time
}
}
}
}
This is the code that simply does the work, counting up each seconds etc. So i tried the code just yo make sure that everything is in order, but during the test I noted that everything seems to have work fined at the try. The systick is set at 1s count down at the moment. Hopefully this is enough. I'm kinda of a beginner in HW programming.