Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/06/08 21:50
Read: times


 
#157289 - if you have a lot to delay by various delays
Responding to: ???'s previous message
if you have a lot to delay by various delays, here is an example. To obtain a delay, you set the app slot (e.g. GCXA10ms[3]) to the "number of delays" and then, either loop or occasionally check for zero.

////////////////////////////////////////////////////////////
//
//  ISR 1: void ISR_T0 (void)
//

void ISR_T0 (void) interrupt 1 using 1
{
U8  T0Ctemp;

  SB0_TCON_TR0 = 0;
  S0_TH0 = HIGH1M1m;
  S0_TL0 = LOW1M1m;
  SB0_TCON_TR0 = 1;

// 1ms counters
  for (T0Ctemp = CNT_1MSE; T0Ctemp != 0 ; T0Ctemp-- )
  {
    if ((GCXA1mse-1)[T0Ctemp])
    {
      (GCXA1mse-1)[T0Ctemp]--;
    }
  }
// 10ms counters  
  if (GCXA1mse[T1M_CNT] == 0)
  {
    GCXA1mse[T1M_CNT] = 10;
    for (T0Ctemp = CNT_10MS; T0Ctemp != 0 ; T0Ctemp-- )
    {
      if ((GCXA10ms-1)[T0Ctemp])
      {
        (GCXA10ms-1)[T0Ctemp]--;
      }
    }
// 100ms counters
    if (GCXA10ms[T10M_CNT] == 0)
    {
      GCXA10ms[T10M_CNT] = 10;
      for (T0Ctemp = CNT_100M; T0Ctemp != 0 ; T0Ctemp-- )
      {
        if ((GCXA100m-1)[T0Ctemp])
        {
          (GCXA100m-1)[T0Ctemp]--;
        }
      }
// 1 sec counters
      if (GCXA100m[T100M_CNT] == 0)
      {
        GCXA100m[T100M_CNT] = 10;
        for (T0Ctemp = CNT_1SEC; T0Ctemp != 0 ; T0Ctemp-- )
        {
          if ((GCXA1sec-1)[T0Ctemp])
          {
            (GCXA1sec-1)[T0Ctemp]--;
          }
        }
      }
    }
  }
}  // end ISR_T0


Erik


List of 27 messages in thread
TopicAuthorDate
Non Blocking timer            01/01/70 00:00      
   Use a hardware timer            01/01/70 00:00      
      Thanks - But.....            01/01/70 00:00      
         State machines            01/01/70 00:00      
            THANKS - That's a great idea            01/01/70 00:00      
               if you have a lot to delay by various delays            01/01/70 00:00      
                  I Like that Idea as well            01/01/70 00:00      
                  A Linked List might be better here            01/01/70 00:00      
                     the correct use takes care of this            01/01/70 00:00      
                        Not necessarily            01/01/70 00:00      
   Cooperative or preemptive multitasking            01/01/70 00:00      
      Super-loop contra cooperative multitasking            01/01/70 00:00      
         Multasking can work on the 8051 ... sometimes            01/01/70 00:00      
            Not just stack            01/01/70 00:00      
               I agree            01/01/70 00:00      
                  Choose your battles carefully            01/01/70 00:00      
               I agree, too            01/01/70 00:00      
                  and            01/01/70 00:00      
                     Never underestimate the usefulnes of interrupts            01/01/70 00:00      
                        a flavor            01/01/70 00:00      
                           prioritizing in super-loop            01/01/70 00:00      
                              the fact is ..            01/01/70 00:00      
                  C works well            01/01/70 00:00      
                  Circular argument?            01/01/70 00:00      
                     Re: Circular Argument            01/01/70 00:00      
                        going round in circles            01/01/70 00:00      
            small multitasker            01/01/70 00:00      

Back to Subject List