Hallo ALL, I have the following problem .... I use F005 from cygnal. I have a timer: ...................................... idata U8 volatile HeartbeatLEDTimer; idata U8 volatile DACTimer; ................................... void Timer0InterruptHandler(void) interrupt 1 using 1 { // Reload the timer registers TR0 = 0; TL0 = T0_RELOAD_LOW; TH0 = T0_RELOAD_HIGH; // DECREMENT_TIMER(HeartbeatLEDTimer); DECREMENT_TIMER(DACTimer); TR0 = 1; } and in the main() /* if(!HeartbeatLEDTimer) {pin_LED_D1 = ~pin_LED_D1; HeartbeatLEDTimer = HEART_BEAT_LED_TIMER;} */ ............................. // INTERRUPTS_OFF; DACTimer=DAC_TIMER; // INTERRUPTS_ON; while(DACTimer != 0){; }//delay it works without INTERRUPTS_OFF if I don't use HeartbeatLEDTimer, but if I use it, I should disable interrupts only before DACTimer=DAC_TIMER and not before HeartbeatLEDTimer = HEART_BEAT_LED_TIMER??? I'm really confused and I thought the problem is in VOLATILE! But it's not so clear. Please help me to understand what here is really happened. With best regards, Sergey
and in the main() /* if(!HeartbeatLEDTimer) { pin_LED_D1 = ~pin_LED_D1; HeartbeatLEDTimer = HEART_BEAT_LED_TIMER; } */ // INTERRUPTS_OFF; DACTimer=DAC_TIMER; // INTERRUPTS_ON; while(DACTimer != 0){; }//delay
Hello ALL! Now it works! The interrurpt should be enabled before while(DACTimer!=0); and I was completely sure that it is , but.... this "while" is in the big setup function befor main loop and in one of the setup subfunction befor this call the Interrupt was disabled and it was deadly for this "while". In any case THANK YOU ALL VERY MUCH for all your help ! With respect, S.