mit Interrupts..
hab paar Code Schnippel ...aber ich weiss nicht welcher von ihnen richtig wäre
Code:interrupt() { if (time_count != 0) time_count--; } main() { some_function(10); } some_function(time_to_run) { time_count = time_to_run; while (time_count != 0) { do stuff } }
oder
Danke für deine HilfeCode:int1 Clock_Been_Initialized=0; Int16 Miliseconds; #locate Miliseconds = Registry_Map+6 Int16 Seconds; #locate Seconds = Registry_Map+8 int1 Second_Tick=0; // Global Real Time Clock Information #int_TIMER2 // Clock interrupt adjusted to occurs ~ 1ms void TIMER2_isr() { Miliseconds++; if(Miliseconds>999) { Miliseconds=0; Seconds++; Second_Tick=1; } } /*********************************************************** * Service Hardware Modules * ***********************************************************/ #inline void Clock_Service(void) { if(!Clock_Been_Initialized) { setup_timer_2(T2_DIV_BY_4,249,1); // Set 1mS period enable_interrupts(INT_TIMER2); Seconds=0; Clock_Been_Initialized=1; } if(Second_Tick) { Second_Tick=0; Registry_Map[6]=Registry_Map[5]; Registry_Map[5]=0; Registry_Map[2]=Registry_Map[1]; Registry_Map[1]=0; } Registry_Map[5]++; }







Zitieren

Lesezeichen