warpigs330
Active member
So I am working on a project where I use millis() and micros() to measure time. Right now I am doing this somewhat poorly, which causes my code to stall when micros() overruns and goes back to zero. I don't think this will be complicated to fix, but I don't want to wait 70 minutes or so every time to see if it is actually fixed. Is there a way to start the sketch with micros() almost out of space so I can test the overrun scenario quickly? Also I would love to hear y'all's general opinions about handling clock overruns. Also any techniques for debugging around edge cases that might not appear in normal testing would be handy.
To give an idea of what I am doing and why I am using millis() and micros(), Basically I am continuously taking samples from an ADC into a buffer, then when I press and hold a button I want to save the section of the buffer that was recorded while holding the button, to a second buffer (since the first is circular and constantly rewritten). I then want to replay the contents of that second buffer at the same rate as it was recorded. So to do this I take the time the button was pressed, the time it was released, and figure out a length (in time) of the recording from that. Also my recording buffer only takes a sample every 100 or so loops, and my recording playback interpolates between these values, so I am also using micros() to find the amount to move forward in the buffer every step.
Thanks for any help y'all can provide.
To give an idea of what I am doing and why I am using millis() and micros(), Basically I am continuously taking samples from an ADC into a buffer, then when I press and hold a button I want to save the section of the buffer that was recorded while holding the button, to a second buffer (since the first is circular and constantly rewritten). I then want to replay the contents of that second buffer at the same rate as it was recorded. So to do this I take the time the button was pressed, the time it was released, and figure out a length (in time) of the recording from that. Also my recording buffer only takes a sample every 100 or so loops, and my recording playback interpolates between these values, so I am also using micros() to find the amount to move forward in the buffer every step.
Thanks for any help y'all can provide.