Create a software trigger in the While loop to start your timer. This could be as simple
as a shift register with a history of two elements on the left side of the While loop.
Feed your boolean to the shift register, and look for the trigger condition based on the
history of boolean elements. If you want to start your timer on low-to-high condition, then
initialize the shift register to 00 and feed a 1 on your starting interation.
Then, look for a 01 in your shift register elements. Similarly, to stop the timer on a high-to-low
condition, feed a 0 to the shift register on your stopping iteration and look for a 10 in your
shift register elements.
To keep the timer running, continuously feed a 1 and check for 11 in the shift register elements.
This is basically a software control signal for your timer.