??? 06/28/10 06:28 Read: times |
#176945 - Avoid ISR jitter using timer T1 Responding to: ???'s previous message |
Also, the time spend in the ISR code between stop T1 and start T1 varies, depending on the
if (++multiplier == 20)comparison. A better way should be to take care of timer T1 first and then make any actions, so to avoid jitter every time the comparison comes true. /*-------------------------------------------- This occurs every 50ms ---------------------------------------------*/ void timer_1_interr(void) interrupt 3 { static unsigned char data multiplier = 0; TR1 = 0; TF1 = 0; TH1 = SOFT_RTC_TH1_RELOAD; //reload timer 1 TL1 = SOFT_RTC_TL1_RELOAD; TR1 = 1; if (++multiplier == 20) { multiplier = 0; soft_RTC_ticks++; } if (multitap_timeout) //dec if not already 0 multitap_timeout--; } and combined with the zero comparison by Per, /*-------------------------------------------- This occurs every 50ms ---------------------------------------------*/ void timer_1_interr(void) interrupt 3 { static unsigned char data multiplier = 20; TR1 = 0; TF1 = 0; TH1 = SOFT_RTC_TH1_RELOAD; //reload timer 1 TL1 = SOFT_RTC_TL1_RELOAD; TR1 = 1; if (--multiplier == 0) { multiplier = 20; soft_RTC_ticks++; } if (multitap_timeout) //dec if not already 0 multitap_timeout--; } K.L.Angelis |
Topic | Author | Date |
Ideas for Multi-tap keyboard routine | 01/01/70 00:00 | |
just follow | 01/01/70 00:00 | |
Multi-tap is not too difficult | 01/01/70 00:00 | |
Two-step operation. Keyboard input + post-processing | 01/01/70 00:00 | |
State Machine! | 01/01/70 00:00 | |
Agree 100% | 01/01/70 00:00 | |
Time to code | 01/01/70 00:00 | |
Software Timers! | 01/01/70 00:00 | |
Practical Limits | 01/01/70 00:00 | |
Don't lock up in infinite loops everywhere | 01/01/70 00:00 | |
In the pseudo code... | 01/01/70 00:00 | |
State Machine | 01/01/70 00:00 | |
Divide by 5 | 01/01/70 00:00 | |
Timer resolution | 01/01/70 00:00 | |
State Machine | 01/01/70 00:00 | |
Looks not bad programming practice | 01/01/70 00:00 | |
Using Timer May Still be Possible | 01/01/70 00:00 | |
Done ! | 01/01/70 00:00 | |
Very Cool!!! | 01/01/70 00:00 | |
Compare with zero is better | 01/01/70 00:00 | |
Avoid ISR jitter using timer T1 | 01/01/70 00:00 | |
Code! | 01/01/70 00:00 | |
Thanks Munish...![]() | 01/01/70 00:00 |