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 in lpc 17xx

hello all

i want to introduce delay in program in microsecond range. can any one give me some examples for lpc17xx.

Thanks in advance.

Parents
  • Just talking about timing, there are a large number of ways to generate some form of delay.

    It's possible to take a SPI device and let it perform x words of transmission at a specific baudrate. There is no need to map any external pins, but the device can generate an interrupt when the virtual "transfer" is done.

    Same thing with taking one of the four UARTs.

    The CAN devices can also be abused.

    A freerunning timer can be used in polling mode, where the current value is retrieved and stored in an unsigned. Then it's enough to constantly retrieve the current value and check if the difference with the start value is >= the requested delay time. This allows the timer to be used with less setup time.

    There are even more ways to measure time in this specific processor. It's just a question of creativity and what delay range that is needed.

Reply
  • Just talking about timing, there are a large number of ways to generate some form of delay.

    It's possible to take a SPI device and let it perform x words of transmission at a specific baudrate. There is no need to map any external pins, but the device can generate an interrupt when the virtual "transfer" is done.

    Same thing with taking one of the four UARTs.

    The CAN devices can also be abused.

    A freerunning timer can be used in polling mode, where the current value is retrieved and stored in an unsigned. Then it's enough to constantly retrieve the current value and check if the difference with the start value is >= the requested delay time. This allows the timer to be used with less setup time.

    There are even more ways to measure time in this specific processor. It's just a question of creativity and what delay range that is needed.

Children
  • If the assembly language program is written in c file using embedded assembler, will it have the same effect as separate assembly program?

    __asm void delay(uint16_t usec)
            {
            MOVS     r1,#0
            B        |L1.6|
    |L1.4|
            ADDS     r1,r1,#1
    |L1.6|
            ADD      r2,r0,r0,LSL #2
            ADD      r2,r2,r0,LSL #3
            CMP      r2,r1
            BGT      |L1.4|
            BX       lr
            ENDP
    
            }