Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Calculate time.

2006-03-14 by Jack Key

The formula is:
   
  peripheral_frequency=oscillator_frequency*pll_multiplier(if pll is enabled)/vpb_dividor
   
  So if your oscillator_frequency is 12MHz, pll_multiplier is 5 and vpb_dividor is 4, the peripheral_frequency would be 15MHz. So for 10msec, the count would be:
   
  Count = peripheral_frequency * time_required
           =   15,000,000 * .01
           =   150,000
   
  So the count to be loaded in T0MR0 is 150000.

teddyroskvist <thr@...> wrote:
  How do i calculate the time?
I have the example you can see herunder.

In the interrupt routine the TOMR0 is set to 149999 because it 
should be 10mSec.

But how do i calculate the number? if i need a another time.

-------------------------------------------------------------------

void tc0 (void) __irq  
{
  T0MR0 = 149999;                // 10mSec = 150.000-1 counts
  T0IR        = 1;               // Clear interrupt flag
  VICVectAddr = 0;               // Acknowledge Interrupt

      if ((IO1SET & 0xff000000) == 0xFF000000)
            IO1CLR = 0xFF000000;
      else
            IO1SET = 0xFF000000;      
}

/* Setup the Timer Counter 0 Interrupt */
void init_timer (void) 
{
  T0MR0 = 149999;                   // 10mSec = 150.000-1 counts

  T0MCR = 3;                        // Interrupt and Reset on MR0
  T0TCR = 1;                        // Timer0 Enable
  VICVectAddr0 = (unsigned long)tc0;// set interrupt vector in 0
  VICVectCntl0 = 0x20 | 4;          // use it for Timer 0 Interrupt
  VICIntEnable = 0x00000010;        // Enable Timer0 Interrupt
}

int main (void)  
{
      unsigned int i;
      IO1DIR = 0xFFff0000;
      init_timer();
      while(1) 
      {
            IO1SET = 0x00FFffff;      
            for (i = 0 ; i < 1000000 ; i++ ){}            
            IO1CLR = 0x00FFffff;      
            for (i = 0 ; i < 1000000 ; i++ ){}            
      };
      return 0;
}





  SPONSORED LINKS 
        Microcontrollers   Microprocessor   Intel microprocessors     Pic microcontrollers 
    
---------------------------------
  YAHOO! GROUPS LINKS 

    
    Visit your group "lpc2000" on the web.
    
    To unsubscribe from this group, send an email to:
 lpc2000-unsubscribe@yahoogroups.com
    
    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 

    
---------------------------------
  



		
---------------------------------
Yahoo! Mail
Bring photos to life! New PhotoMail  makes sharing a breeze. 

[Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.