Yahoo Groups archive

Lpc2000

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

Message

RE: [lpc2100] Delay routines

2004-01-02 by Curt Powell

Robert,
 
I ran some side-by-side comparisons on the first vs. the second versions
of delay that you posted.  
Because I know there is call overhead I just put the delay routines in a
loop that sets a pin high, delays, sets pin low, etc. and looked at
differences from delay to delay on a logic analyzer, i.e.:
for (i=2;i<=10;++i)
{
    -drive output pin high
    WaitUs(i);
    -drive output pin low
}
-drive trigger high
 
The results are interesting (at least to me).  First, there is a
potential bug in both versions:
Using my CLOCK_SPEED of 14,745,000hz , processor speed of 58,980,000 and
a VPB divider of 2 so VPBRate() is 29,490,000, a call to WaitUs(1) takes
many minutes to execute.  It hangs in
 
while( (REG(TIMER0_EMR) & 0x8) == 0).  
 
WaitUs for values > 1 succeeds.  I assume that with a value of 1 the
timer has to go "around the horn" to get back to the target value, hence
the delay.
However, if I use your original CLOCK_SPEED of 10,000,000 it works OK.
I haven't tracked down in the code why this is happening but I wonder
that with such a short delay the counter is already past the target
value before the match gets set?
 
Delays that the logic analyzer (el-cheapo ant16) reports are
interesting:
i(uS, requested)    Delay (uS, measured)   Difference from previous
----------------    ----------------       ------------------------
2                   12                     
3                   12.8                   0.8
4                   13.7                   0.9
5                   14.9                   1.2
6                   15.9                   1.0
7                   16.9                   1.0
8                   18                     1.1
9                   18.8                   0.8
10                  19.8                   1.0
(These are pretty reproducible from run to run)
 
So there seems to be a constant overhead factor of 10us in the call.  
 
Question 1:  Does this overhead seem excessive to you for the processor
running at 60Mhz?  
Question 2:  Does the variation in 'difference from previous' seem
excessive?
 
Anyone else with thougths/observations/experiences feel free to chime
in...
 
Curt
 
-----Original Message-----
From: Robert Adsett [mailto:subscriptions@...] 
Sent: Tuesday, December 30, 2003 1:10 PM
To: lpc2100@yahoogroups.com
Subject: RE: [lpc2100] Delay routines



At 10:01 AM 12/20/03 -0500, you wrote:
>My routine uses the nominal rate, the PLL multiplier and the VPB
divider to
>work out what the rate is.  I'll make it available (probably by years
end)
>as soon as I've cleaned it up a bit.  Right now it's between
>implementations.  It'll be part of a set of newlib routines.

I promised I'd make the newlib routines I mentioned available by the end
of 
the year.  It looks like I'll have a day to spare :).  They are 
downloadable in a zip file from

http://www.aeolusdevelopment.com/Articles/download.html

This has timer (and delay) support as well as stdin/stdout/stderr
support 
for newlib.  Also some CPU setup routines.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III



  _____  

Yahoo! Groups Links


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

*	To unsubscribe from this group, send an email to:
lpc2100-unsubscribe@yahoogroups.com
<mailto:lpc2100-unsubscribe@yahoogroups.com?subject=Unsubscribe> 
  

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

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.