I am trying to understand the concepts of 'Elapsed Time,' 'Current Time,' and 'Previous Time' within the context of a 1ms timer used to generate alerts at specific time intervals, such as 15ms and 22ms.
Let's assume we have three variables - 'current_time,' 'previous_time,' and 'elapsed_time' - that will help me to know these concepts in this timing scenario. The 'current_time' variable increments each time a timer interrupt occurs. Specifically, when 'current_time' reaches a value of 15, alerts should be generated to indicate that 15ms have passed.
When 'current_time' reaches 22, alerts should be generated to indicate that 22ms have passed.
When 'current_time' is 15ms and 'previous_time' is 0ms, the correct calculation for 'elapsed_time' should be:
elapsed_time = current_time - previous_time = 15ms - 0ms = 15ms
Let's assume we have three variables - 'current_time,' 'previous_time,' and 'elapsed_time' - that will help me to know these concepts in this timing scenario. The 'current_time' variable increments each time a timer interrupt occurs. Specifically, when 'current_time' reaches a value of 15, alerts should be generated to indicate that 15ms have passed.
When 'current_time' reaches 22, alerts should be generated to indicate that 22ms have passed.
When 'current_time' is 15ms and 'previous_time' is 0ms, the correct calculation for 'elapsed_time' should be:
elapsed_time = current_time - previous_time = 15ms - 0ms = 15ms