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

Problem in Creating Nano Secs Delay using 1768 in ISP mode

Hi,
i am trying to create Nano secds delay, but i got delay in micro secds so, plz help me ...

my timer configurations are......

void Timer_Init()
{
                LPC_SC->PCONP                =       (1<<1);                                                   LPC_TIM0->TCR        |= 1 << 0;
                LPC_TIM0->PR          = 3;
          LPC_TIM0->MR0       = 2;

    LPC_TIM0->MCR    |= 1 << 0;
    LPC_TIM0->MCR    |= 1 << 1;
    NVIC_EnableIRQ(TIMER0_IRQn);

                LPC_TIM0->TCR        |= (1<<1);
                LPC_TIM0->TCR &= ~(1<<1);
}
</prev>
Here i am not using PLL here...PCLK=12MHz.... suzzes me which values are Sutable for MR0 And PR0.....to create nano secands Delay...


Parents
  • PCL = 12MHz means each tick is 83 ns.

    Even if you have a resolution of 83 ns, that doesn't mean you can create an interrupt-driven solution that gives nanosecond delays. The latency of the interrupt is a significant number of machine cycles...

    It's only when letting the timer control an external pin, that you can manage very short periods. When the timer drives an external pin, it doesn't matter how many machine cycles the CPU needs for processing some code, since the CPU isn't involved.

    Byt any form of delays involving the CPU will also involve the instruction processing speed of the processor.

    So why not settle for something your processor is actually capable of doing?

Reply
  • PCL = 12MHz means each tick is 83 ns.

    Even if you have a resolution of 83 ns, that doesn't mean you can create an interrupt-driven solution that gives nanosecond delays. The latency of the interrupt is a significant number of machine cycles...

    It's only when letting the timer control an external pin, that you can manage very short periods. When the timer drives an external pin, it doesn't matter how many machine cycles the CPU needs for processing some code, since the CPU isn't involved.

    Byt any form of delays involving the CPU will also involve the instruction processing speed of the processor.

    So why not settle for something your processor is actually capable of doing?

Children