Question: Custom callback code: Now, create a new global variable, initializing it to zero, for storing the time in milliseconds. Create a second global variable (

Custom callback code: Now, create a new global variable, initializing it to zero, for storing the
time in milliseconds. Create a second global variable (also initialized to zero) to store the time
in seconds.
Implement custom code in timer_callback() that increments the new ms counter variable
every time the function is called.
Implement logic that ensures that if the current time in milliseconds is equal to or greater
than one second, it:
Decrements its own value by the ms equivalent of one second.
Increments the seconds variable by the equivalent of one second.
Toggles the on-board LED digital output
Note: This code should work if the time in ms is any value over than 1 second.
Note 2: This code should be written so as it doesn't reset, clear, truncate, or lose time
information.
In the while loop in main(), add code that
computes the current time as a float in seconds (with milliseconds behind the decimal
point)
fills and prints a string with the current time in seconds, starting with "t=" and ending with
"s" using
Example:
t=45.34s
Note: It is bad practice to put printf() or sprintf() functions in a callback because it takes so much
time to process.
Custom callback code: Now, create a new global

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!