Skip to main content
6 events
when toggle format what by license comment
Jun 7, 2023 at 14:47 vote accept RickyBoy
Jun 7, 2023 at 14:47 comment added RickyBoy Thanks very much
Jun 7, 2023 at 12:28 comment added glen_geek RickyBoy - "-=" or "+=" as you please. When you leave home, do you count the kilometers from home, or kilometers to your destination? Consider code readability for someone else. Slightly safer to add/subtract TMR0 early in the ISR while its count value is low, to avoid potential math overflow if TMR_RESET_VALUE approaches 255.
Jun 7, 2023 at 9:53 comment added RickyBoy Thanks for this answer, lots of very useful info. I wonder whether: a) the reset should be TMR += TMR_RESET_VALUE b) the reset should be the last line of the ISR I did this and I now have both LEDs only 1% off-target. (Agree about the use of PWM - this exercise was simply one for me to learn the use of timers and their interrupts - the ultimate application requires it)
Jun 7, 2023 at 4:00 history edited glen_geek CC BY-SA 4.0
Tried MPLAB's simulator and found anomolies with subtracting a constant from a running TMR0
Jun 6, 2023 at 19:32 history answered glen_geek CC BY-SA 4.0