??? 09/15/04 10:37 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#77430 - RE: Priority interrupt problem with DS5240 Responding to: ???'s previous message |
A couple of guesses here: Declare your vars in the interrupt as 'static'. This might fix your problem directly. 'Static' allocates memory for the variable rather than using the variable pool. The other item which I doubt is causing your problem is when you reload the timer do it as soon as possible in your isr - this is so you don't introduce variable times due to the different execution time of your code - The timer can't re-interrupt since you have yet to do a RETI. #define TIMER_RELOAD 0xfffd //set timer for 10mS //Timer 0 Interrupt manages a virtual timer table void timer0 (void) interrupt 1 using 3 { static data unsigned char *ptabella; static data unsigned char i; TR0 = 0; //TL0 = (unsigned char)LO_T0; //TH0 = (unsigned char)HI_T0; TL0 = TIMER_RELOAD & 0x00ff; TH0 = TIMER_RELOAD >> 8; //a slightly different of handling the constant! TR0 = 1; ptabella = (unsigned char data*) &timer10ms; for( i = 0; i < LENTIMER10MS; i++ ) { if( (*ptabella) !=0 ) (*ptabella)--; ptabella++; } if( --prescaler_50ms == 0 ) { prescaler_50ms = VALUE_50MS; ptabella = (unsigned char data*)&timer50ms; for( i = 0; i < LENTIMER50MS; i++ ) { if( (*ptabella) !=0 ) (*ptabella)--; ptabella++; } if( --prescaler_1sec == 0 ) { prescaler_1sec = VALUE_1SEC; ptabella =(unsigned char data*)&timer1sec; for( i = 0; i < LENTIMER1SEC; i++ ) { if( (*ptabella) !=0 ) { (*ptabella) --; } ptabella++; } } } } |