| ??? 10/11/12 21:58 Read: times |
#188629 - The timer simply increments Responding to: ???'s previous message |
Sorry for any confusion
The timer ISR is
void ONE_KHZ_ISR (void) interrupt 5 {
TF2 = 0; // Reset Interrupt
WDTCN = 0xA5;
gui_mSecCount++;
gb_mSecTick = TRUE;
timer_count++; //this is count for our sort out timers tick
//we use this to make sure we don't miss a timer event
//if we take too long processing something, this will always fire.
}
I would have thought that is pretty short..... Then at some non critical non ISR point in my code I call. TIMERS_sort_out_timers();
//call this on a 1mSec or more tick that is not on an interrupt.
void TIMERS_sort_out_timers(void){
unsigned char i;
unsigned int elapsed_msecs;
elapsed_msecs = timer_count;
timer_count = 0;
for (i = 0; i < NUMBER_OF_TIMERS; i++){ //step through each of our timers
if (timer_array[i].current_value != 0){ //see if we have already expired.
// timer_array[i].current_value --; //if not then decrement the timer toward 0
timer_array[i].current_value -= elapsed_msecs; //if not then decrement the timer toward 0 or past 0
if (timer_array[i].current_value <= 0){ //now see if we have timed out
if (timer_array[i].timer_type == timer_periodic){ //if we run on a periodic timer
timer_array[i].current_value = timer_array[i].reset_value; //reload the timer
}
timer_array[i].timeout_func(timer_array[i].func_args); //if we have timed out then perform the function in our callback.
}
}
}
}
In this manner I am not hanging around in an interrupt. And I'm not processing an expired timer in the ISR? Regards Marshall |
| Topic | Author | Date |
| Timers - Function Pointers | 01/01/70 00:00 | |
| Too much for a '51? | 01/01/70 00:00 | |
| I Agree | 01/01/70 00:00 | |
| Function Pointers... | 01/01/70 00:00 | |
| you are violating KISS | 01/01/70 00:00 | |
| Various Timer Functions | 01/01/70 00:00 | |
| Thanks Michael | 01/01/70 00:00 | |
| regardless, you are violating KISS | 01/01/70 00:00 | |
| even on ARM | 01/01/70 00:00 | |
| The timer simply increments | 01/01/70 00:00 | |
| bug | 01/01/70 00:00 | |
| more bugs | 01/01/70 00:00 | |
thanks | 01/01/70 00:00 |



