EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Standard delay routines

Started by Csaba Zvekan March 21, 2009
Hi,

Newbi here. I have a GNUARM install with newlib and was wondering where could I find some delay routines. That are more or less precise to my LPC2103 system clock. Meaning it knows the actual clock speed and calculates the delay routines accordingly.
Like delay_us(int) or delay_us(int) etc would be nice. Or if I already have it what library should I include.
I have been looking here since I saw something in another thread.

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

But then didn't know how to add these new libraries to the compiler. Do I need to build my GCC again and include these libraries as well ? Or can I simply have a folder and add it to my include folders in Eclipse ?
I also saw the waitUs() routine that looks like something I might need ?

I know I have a few question but I am kind of stuck here and believe somebody can probably point me into the right direction .

Any help greatly appreciated
Thanks
Csaba

An Engineer's Guide to the LPC2100 Series

Csaba Zvekan wrote:
> Hi,
>
> Newbi here. I have a GNUARM install with newlib and was wondering where could I find some delay routines. That are more or less precise to my LPC2103 system clock. Meaning it knows the actual clock speed and calculates the delay routines accordingly.
> Like delay_us(int) or delay_us(int) etc would be nice. Or if I already have it what library should I include.
> I have been looking here since I saw something in another thread.
>
> http://www.aeolusdevelopment.com/Articles/download.html
>
> But then didn't know how to add these new libraries to the compiler. Do I need to build my GCC again and include these libraries as well ? Or can I simply have a folder and add it to my include folders in Eclipse ?
> I also saw the waitUs() routine that looks like something I might need ?
>
> I know I have a few question but I am kind of stuck here and believe somebody can probably point me into the right direction .

You could remove the existing stub routines from your copy of newlib and
use the newlib_lpc routines instead.

Or if you just want the timing routines you should be able to use them
without needing the whole library. The main timing routines are in

sys_time.c

In addition some support is in

sys_vpb.c -- Provides support for controlling and reading the state of
the VPB

sys_pll.c -- Controls the PLL and keeps track of the actual clock rate.

With those and the header files you should have high precision delay
routines with a large dynamic range. You will want to double check the
2103 shares the same timing peripherals as the 2106, I haven't checked
that but I think it's close.

A key question will be how short a delay do you need. Check the app
notes for some information on the accuracy and limits on the delay routines.

Robert
--
http://www.aeolusdevelopment.com/

From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time? 37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live....
we currently have stock."
Am Samstag 21 Mz 2009 15:58 schrieb Csaba Zvekan:
> Hi,
>
> Newbi here. I have a GNUARM install with newlib and was wondering
> where could I find some delay routines. That are more or less
> precise to my LPC2103 system clock. Meaning it knows the actual
> clock speed and calculates the delay routines accordingly. Like
> delay_us(int) or delay_us(int) etc would be nice. Or if I already
> have it what library should I include.

For busy-waiting, have a look at the attached routine (GPL).

--

carpe noctem engineering
Ingenieurbuero fuer Hard- & Software-Entwicklung Andreas Pretzsch
Dipl.-Ing. (FH) Andreas Pretzsch Tel. 0731/98588-800
Marlene-Dietrich-Strasse 5 Fax: 0731/98588-801
89231 Neu-Ulm, Germany email: a...@cn-eng.de


Am Sonntag 22 Mz 2009 20:49 schrieb Andreas Pretzsch:
> Am Samstag 21 Mz 2009 15:58 schrieb Csaba Zvekan:
> > Hi,
> >
> > Newbi here. I have a GNUARM install with newlib and was wondering
> > where could I find some delay routines. That are more or less
> > precise to my LPC2103 system clock. Meaning it knows the actual
> > clock speed and calculates the delay routines accordingly. Like
> > delay_us(int) or delay_us(int) etc would be nice. Or if I already
> > have it what library should I include.
>
> For busy-waiting, have a look at the attached routine (GPL).

Due to the famous idea that the mailinglist removes attachments, grab it
from there: http://tech.groups.yahoo.com/group/lpc2000/files/
It's called "delay.zip".

--

carpe noctem engineering
Ingenieurbuero fuer Hard- & Software-Entwicklung Andreas Pretzsch
Dipl.-Ing. (FH) Andreas Pretzsch Tel. 0731/98588-800
Marlene-Dietrich-Strasse 5 Fax: 0731/98588-801
89231 Neu-Ulm, Germany email: a...@cn-eng.de
Thank you Andreas,

I just tested it and it works like a charm. Very nice little routine.
My next question is rather a new topic or even off Forum. Maybe I'll
get an answer anyway. Since I am working in Eclipse"Ganymede" I would
like to have a common User Library . I wanna be able to have delay.h
for all my Projects. How do you guys organize things like that and how
is it done ?

Again, thank you so much for your help

Csaba

On Mar 22, 2009, at 8:59 PM, Andreas Pretzsch wrote:

> Am Sonntag 22 Mz 2009 20:49 schrieb Andreas Pretzsch:
>> Am Samstag 21 Mz 2009 15:58 schrieb Csaba Zvekan:
>>> Hi,
>>>
>>> Newbi here. I have a GNUARM install with newlib and was wondering
>>> where could I find some delay routines. That are more or less
>>> precise to my LPC2103 system clock. Meaning it knows the actual
>>> clock speed and calculates the delay routines accordingly. Like
>>> delay_us(int) or delay_us(int) etc would be nice. Or if I already
>>> have it what library should I include.
>>
>> For busy-waiting, have a look at the attached routine (GPL).
>
> Due to the famous idea that the mailinglist removes attachments,
> grab it
> from there: http://tech.groups.yahoo.com/group/lpc2000/files/
> It's called "delay.zip".
>
> --
>
> carpe noctem engineering
> Ingenieurbuero fuer Hard- & Software-Entwicklung Andreas Pretzsch
> Dipl.-Ing. (FH) Andreas Pretzsch Tel. 0731/98588-800
> Marlene-Dietrich-Strasse 5 Fax: 0731/98588-801
> 89231 Neu-Ulm, Germany email: a...@cn-eng.de
>

Memfault Beyond the Launch