RE: introduce Delay in MPC565 !
praveen <[email protected]> Thu, 24 Aug 2006 09:27:36 -0700 (PDT)
| Newsgroups | gmane.comp.hardware.motorola.microcontrollers |
|---|---|
| Message-ID | <[email protected]> |
Hi ,
OSCCLK is 4Mhz ,
by using PLL we get , System Clock is Configured to 40Mhz.
When System Clk is divided by 16 (as TBS bit in SCCR register is set to 1)
then the Per Count delay becomes 400 nano seconds.(T = 1/2.5Mhz = 400nsec)
But i want something minimum of 10 nano seconds in application.
Plz let me know configurations to be done to acheive this .
- Praveen
Dobbin Allan-r11834 <[email protected]> wrote:
1) is wrong - SCCR[TBS]=0 is OSCCLK divided by 4 or 16. OSCCLK is your external input clock frequency.
Using "==" is risky because you could miss the count if you are running from slow memory or get an interrupt.
- Allan
________________________________
From: [email protected] [mailto:[email protected]] On Behalf Of praveen
Sent: Thursday, August 17, 2006 6:07 AM
To: [email protected]
Subject: RE: [MPC500] introduce Delay in MPC565 !!
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] <mailto:Allan.Dobbin%40freescale.com> > 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:MPC500%40yahoogroups.com> [mailto:[email protected] <mailto:MPC500%40yahoogroups.com> ] On Behalf
Of praveen
Sent: Wednesday, August 16, 2006 6:31 AM
To: [email protected] <mailto:MPC500%40yahoogroups.com>
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]
[Non-text portions of this message have been removed]
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min.
[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/