Keil™, An ARM® Company

Discussion Forum

delay function

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
HARSHADA NEHETE
Posted
12-May-2008 04:12
Toolset
ARM
New! delay function

hi
i am using lpc 2134 for my project.i have installed the real view Uvision3 kit.
i have successfully run the hello world program.
i now want to start my own project.i have included the lpc21**.h file in my program and also the appropriate startup.s file.
i want to write a delay routine of 1200ms.which function should i call.also if i want to write serial port,timer functions or rtc functions which files should i include or which functions do i call.
is there any function prototype defined for these.
kindly reply
thanks
harshada

Read-Only
Author
jalim barfok
Posted
12-May-2008 04:23
Toolset
ARM
New! RE: delay function

hi harashadara,

i use funktion delay with a number in brackets for how long i want. you must put in 97 for delay of 1200 becoz 1 is 12.37MS.

Read-Only
Author
Per Westermark
Posted
12-May-2008 06:03
Toolset
ARM
New! RE: delay function

jalim barfok: Don't post random answers just for fun. It really isn't fun!

For your delay, you should configure a processor timer to tick at a suitable frequency. Then you can either have the timer generate an interrupt after 1200ms, or create a busyloop that samples the tick counter and then waits until the tick counter has stepped the required number of ticks.

Let's say that the counter ticks once/ms. Then you could do:

<code>
void delay_ms(unsigned ms) { unsigned t0 = tick_counter; while (tick_counter - t0 < ms) ;
} </code>

You really have to spend some time reading through the user manual for your processor. It contains the information about how to configure the UARTS etc. Also look at the available sample code. But in the end, _you_ will have to write code for your processor. The difference between microcontrollers and a PC is that you don't have a thick driver layer with a full set of functions to call.

Read-Only
Author
jalim barfok
Posted
12-May-2008 06:20
Toolset
ARM
New! RE: delay function

per westermark see:

http://www.keil.com/forum/tips.asp

Read-Only
Author
Per Westermark
Posted
12-May-2008 06:36
Toolset
ARM
New! RE: delay function

No, it's more a problem with posting to more than one forum, and of getting a phone call at the end of the post. Since I needed my keyboard for the phone call, the fastest method was Preview+Post in a very, very big hurry.

Anyway, I still think I have at lest 99% correctly formatted posts ;)

Read-Only
Author
jalim barfok
Posted
12-May-2008 06:39
Toolset
ARM
New! RE: delay function

bcoz of past records and goodly excuse, we forgive you on this time ;)

Read-Only
Author
Per Westermark
Posted
12-May-2008 06:50
Toolset
ARM
New! RE: delay function

Thank you very much!

I'll try to behave!

Read-Only
Author
Tamir Michael
Posted
12-May-2008 10:50
Toolset
ARM
New! RE: delay function

jalim,
I really don't want to sound rude, but sometimes I regret that Keil do not automatically apply tags to verify correct and no-nonsense English! "bcoz?" like, duh?

Next Thread | Thread List | Previous Thread Start a Thread | Settings