Because I did the math for calculating TH0. You missed subtracting 256-29Why do you think that led doesn't toggle approx 40 ms time?
AND even if the timer had a 1ms period, you are only counting 29 of them, not 40.
AND you are not reloading the timer after an overflow so it will run at the full 8.88ms period after the first time
AND you are manually setting TF0 just before you test for the first overflow so whatever you set the timer to the first time is ignored anyway
So.. that’s why I don’t think it’s toggling at 40ms intervals.
Personally, I would have re-checked my work before asking a question and waiting hours or days for a clarification. If you are going to survive your year end project, you need to do that.
Anyway, you can do a rough time time test by using a stopwatch (smartphone) and timing some number of counts - 20 or more. You can also take a smartphone video of the flashing. Replay the video. Stop and slide through the replay and observe the timeline values between flashes. If your IDE has a simulator, you can use it to time program execution between breakpoints. Lot of options to try..
Last edited: