This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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

Parents
  • 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.

Reply
  • 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.

Children