RE: introduce Delay in MPC565 !!

praveen <[email protected]> Thu, 17 Aug 2006 04:07:22 -0700 (PDT)
Newsgroups gmane.comp.hardware.motorola.microcontrollers
Message-ID <[email protected]>
Thanks for the reply
     System Clk is at 40Mhz, and  i am using TB with SCCR(TBS)=0. 
     So TMBClk division is set to 4.
   
  System Clock  is   :    TB_FREQ = 40Mhz / 4 = 10Mhz
  Per count Value Calculated is : TB_Count = 1 / TB_FREQ =  1/ 10Mhz = 10 nano sec
  Hence the delay per count got is  =  10 nano sec.
  1) Is the above way derived is correct ?
   
  Consider  1000 nano seconds delay ,  can i implement like below :
  nano_second_delay( int nanosecs )
 {
  int t1,t2,t3 ;
    t2  =   nanosecs/10;     // Total count to be checked for
    t1 = get_tb_time();
    t3= t1 +  t2;
      while(1)
      {
        if(get_tb_time() == t3)
          break;
      }
  }
   
  get_tb_time ( void )
{
mftb r3,TB 
}

  2) Whether this will fetch me 1000ns delay  ?
   
  Praveen
   
   
  
Dobbin Allan-r11834 <[email protected]> wrote:
          The best resolution you could possibly hope for is the sysclk i.e. if
you run at, say, 40MHz, the best you could get is 25ns. Using the TB,
this is reduced further to the TMBCLK period as controlled by SCCR and
is typically sysclk divided by a further 16.

So although I'm not providing the answer (because I don't really know),
the real question is which counter module can be clocked with the
smallest prescaler i.e. another core register, MIOS counter, etc.

A comment on your function below - there will be an overhead of a couple
of dozen instructions multipled by the memory access rate (approx a few
micro-secs) which you could subtract from 'microsecs' to get a more
accurate delay, obviously taking care not to go below 0. 

- Allan

________________________________

From: [email protected] [mailto:[email protected]] On Behalf
Of praveen
Sent: Wednesday, August 16, 2006 6:31 AM
To: [email protected]
Subject: [MPC500] introduce Delay in MPC565 !!

Hi all,
I am working with MPC565. and i have made a routine which can introduce
delay in microseconds.

Dummy Routine to Introduce Delay in MicroSeconds :
----------------------------------------------------------
micro_second_delay( int microsecs )
{
int time_base_start = get_tb_time();

//Keep wait until the parameter 
while( ( get_tb_time() - time_base_start ) < microsecs ); 
}

get_tb_time ( void )
{
mftb r3,TB 
}
----------------------------------------------------------
Is it possible to have a function which can introduce delay in
nanoseconds ?
i know that ,TB register is 64-bit incrementing counter. 
how will i be able to manage to get specific delay ? Can i make generic
funtions ?

Thanks in advance 

Praven 

---------------------------------
How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call
rates.

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

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



         

 		
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.

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



-----------------------------------------------------------
To learn more about Freescale Microcontrollers, please visit
http://www.freescale.com/mcu


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/MPC500/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/