Reply by Robert Adsett December 18, 20052005-12-18
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/


An Engineer's Guide to the LPC2100 Series

Reply by Richard Duits December 18, 20052005-12-18
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:

> 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@lpc2..., 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.
> > >
> > >
> > >
> >. >
>




Reply by dennis_arm December 18, 20052005-12-18
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@lpc2..., 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.
> >
> >
> >




Reply by Richard Duits December 14, 20052005-12-14
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. >
> >. >
>




Reply by dennis_arm December 14, 20052005-12-14
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.