Yahoo Groups archive

Lpc2000

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

Thread

how to delay LPC2294 without timmer..?

how to delay LPC2294 without timmer..?

2005-12-14 by dennis_arm

Hi All !!
I am new to LPC2294 and wish to produce a small code for delay some 
thing like 

void delay (unsigned int Usec)
{
   unsigned int delayUsec= ( ?? ) * Usec;          // line 1
   volatile unsigned int count = 0;                 // line 2
   for (count = 0; count < delayUsec; count++)      //line 3
             {asm volatile ("nop");}               // line 4
}
 where time is the no of micro seconds 
for information I am using a 60MHz crystal on my board

I know it is easy to do with timers 0 and 1 but i wish, NOT to use 
the timers at all as i need them for orther purpose.
My question 
1. is that is there any overhead added due to the code in the 
function for the lines 1,2,3,4 ?
2. is there any over head due to this "delay(/*some value*/)" being 
called in my over all code.?

          If so how much delay? or where can i get the information?

Am i missing some thing or is there a simple way to do this (to 
caliculate the delay with out using tmmers?)


thanks in advance!!

regards,
dennis.

Re: [lpc2000] how to delay LPC2294 without timmer..?

2005-12-14 by Richard Duits

Hi Dennis,

I usually write short delays like this:

void delay(unsigned int ticks)
{
  unsigned int start = Timer0_TC;
  while (Timer0_TC - start < ticks) { }
}


This does not use any match registers, you only need a timer that does 
not reset its counter.

Regards,
Richard.


dennis_arm wrote:
Show quoted textHide quoted text
> Hi All !!
> I am new to LPC2294 and wish to produce a small code for delay some
> thing like
>
> void delay (unsigned int Usec)
> {
>    unsigned int delayUsec= ( ?? ) * Usec;          // line 1
>    volatile unsigned int count = 0;                 // line 2
>    for (count = 0; count < delayUsec; count++)      //line 3
>              {asm volatile ("nop");}               // line 4
> }
> where time is the no of micro seconds
> for information I am using a 60MHz crystal on my board
>
> I know it is easy to do with timers 0 and 1 but i wish, NOT to use
> the timers at all as i need them for orther purpose.
> My question
> 1. is that is there any overhead added due to the code in the
> function for the lines 1,2,3,4 ?
> 2. is there any over head due to this "delay(/*some value*/)" being
> called in my over all code.?
>
>           If so how much delay? or where can i get the information?
>
> Am i missing some thing or is there a simple way to do this (to
> caliculate the delay with out using tmmers?)
>
>
> thanks in advance!!
>
> regards,
> dennis.
>
>
>
>
>
> ------------------------------------------------------------------------
> YAHOO! GROUPS LINKS
>
>     *  Visit your group "lpc2000
>       <http://groups.yahoo.com/group/lpc2000>" on the web.
>        
>     *  To unsubscribe from this group, send an email to:
>        lpc2000-unsubscribe@yahoogroups.com
>       <mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>        
>     *  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>       Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------------------------------------------------
>

Re: how to delay LPC2294 without timmer..?

2005-12-18 by dennis_arm

Thank u Richard,

I hope this works for me.

but i am still left with my questions
about the overhead due to the inlization and comparing ..
in while and for loops..
 can u say something on this pls?

regards,
dennis
--- In lpc2000@yahoogroups.com, Richard Duits <yahoo@r...> wrote:
>
> Hi Dennis,
> 
> I usually write short delays like this:
> 
> void delay(unsigned int ticks)
> {
>   unsigned int start = Timer0_TC;
>   while (Timer0_TC - start < ticks) { }
> }
> 
> 
> This does not use any match registers, you only need a timer that 
does 
> not reset its counter.
> 
> Regards,
> Richard.
> 
> 
> dennis_arm wrote:
> 
> > Hi All !!
> > I am new to LPC2294 and wish to produce a small code for delay 
some
> > thing like
> >
> > void delay (unsigned int Usec)
> > {
> >    unsigned int delayUsec= ( ?? ) * Usec;          // line 1
> >    volatile unsigned int count = 0;                 // line 2
> >    for (count = 0; count < delayUsec; count++)      //line 3
> >              {asm volatile ("nop");}               // line 4
> > }
> > where time is the no of micro seconds
> > for information I am using a 60MHz crystal on my board
> >
> > I know it is easy to do with timers 0 and 1 but i wish, NOT to use
> > the timers at all as i need them for orther purpose.
> > My question
> > 1. is that is there any overhead added due to the code in the
> > function for the lines 1,2,3,4 ?
> > 2. is there any over head due to this "delay(/*some value*/)" 
being
> > called in my over all code.?
> >
> >           If so how much delay? or where can i get the 
information?
Show quoted textHide quoted text
> >
> > Am i missing some thing or is there a simple way to do this (to
> > caliculate the delay with out using tmmers?)
> >
> >
> > thanks in advance!!
> >
> > regards,
> > dennis.
> >
> >
> >

Re: [lpc2000] Re: how to delay LPC2294 without timmer..?

2005-12-18 by Richard Duits

The overhead is very compiler dependant and the best way is to take a 
look at the list file generated by the compiler. Your simple loop may 
also be longer if there are any interrupts during the loop execution.

Richard.

dennis_arm wrote:
Show quoted textHide quoted text
> Thank u Richard,
>
> I hope this works for me.
>
> but i am still left with my questions
> about the overhead due to the inlization and comparing ..
> in while and for loops..
> can u say something on this pls?
>
> regards,
> dennis
> --- In lpc2000@yahoogroups.com, Richard Duits <yahoo@r...> wrote:
> >
> > Hi Dennis,
> >
> > I usually write short delays like this:
> >
> > void delay(unsigned int ticks)
> > {
> >   unsigned int start = Timer0_TC;
> >   while (Timer0_TC - start < ticks) { }
> > }
> >
> >
> > This does not use any match registers, you only need a timer that
> does
> > not reset its counter.
> >
> > Regards,
> > Richard.
> >
> >
> > dennis_arm wrote:
> >
> > > Hi All !!
> > > I am new to LPC2294 and wish to produce a small code for delay
> some
> > > thing like
> > >
> > > void delay (unsigned int Usec)
> > > {
> > >    unsigned int delayUsec= ( ?? ) * Usec;          // line 1
> > >    volatile unsigned int count = 0;                 // line 2
> > >    for (count = 0; count < delayUsec; count++)      //line 3
> > >              {asm volatile ("nop");}               // line 4
> > > }
> > > where time is the no of micro seconds
> > > for information I am using a 60MHz crystal on my board
> > >
> > > I know it is easy to do with timers 0 and 1 but i wish, NOT to use
> > > the timers at all as i need them for orther purpose.
> > > My question
> > > 1. is that is there any overhead added due to the code in the
> > > function for the lines 1,2,3,4 ?
> > > 2. is there any over head due to this "delay(/*some value*/)"
> being
> > > called in my over all code.?
> > >
> > >           If so how much delay? or where can i get the
> information?
> > >
> > > Am i missing some thing or is there a simple way to do this (to
> > > caliculate the delay with out using tmmers?)
> > >
> > >
> > > thanks in advance!!
> > >
> > > regards,
> > > dennis.
> > >
> > >
> > >
>
>
>
>
>
> ------------------------------------------------------------------------
> YAHOO! GROUPS LINKS
>
>     *  Visit your group "lpc2000
>       <http://groups.yahoo.com/group/lpc2000>" on the web.
>        
>     *  To unsubscribe from this group, send an email to:
>        lpc2000-unsubscribe@yahoogroups.com
>       <mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>        
>     *  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>       Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------------------------------------------------
>

Re: [lpc2000] Re: how to delay LPC2294 without timmer..?

2005-12-18 by Robert Adsett

At 12:06 PM 12/18/05 +0000, dennis_arm wrote:
>Thank u Richard,
>
>I hope this works for me.
>
>but i am still left with my questions
>about the overhead due to the inlization and comparing ..
>in while and for loops..
>  can u say something on this pls?

Take a look at 
http://www.aeolusdevelopment.com/AppNotes/LPC210X/an-timerperformance.pdf 
I did exactly that kind of measurement for the timer set up in 
newlib-lpc.  Feel free to take a look at that code for some thoughts on how 
to approach it.  The code is also free for the taking ;)

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
http://www.aeolusdevelopment.com/

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.