Programmable Delay Block

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Programmable Delay Block

1,289 Views
john71
Senior Contributor I

Can I use Programmable Delay Block (PDB) as a delay mechanism?
Say instead of

for (i = 0; i < delay; i++) ;

If so -is there some example?

5 Replies

962 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Evgeny Erenburg,

You can use Programmable Delay Block (PDB) as a delay mechanism.

Please download the MCUXpresso SDK_2.4.0 and find the delay_interrupt example.

delay_interrupt.png

All these hardware timer is able to achieve it.

Timer.png

 

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

962 Views
john71
Senior Contributor I

Thank you. MCUXpresso dosen't support my MK10FN1M0VLQ12.

0 Kudos

962 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Unfortunately, at the moment there is no plan to support this part number with SDK libraries.

 

Best Regards,

Robin

0 Kudos

961 Views
mjbcswitzerland
Specialist V

Evgeny

The PDB is useful for controlling sampling points but not for software delays.


See example in chapter 3 of http://www.utasker.com/docs/uTasker/uTaskerADC.pdf


For accurate software wait type delays you can use the SYSTICK. Here is the method used in the uTasker project to wait a defined number of microseconds.

extern void fnDelayLoop(unsigned long ulDelay_us)
{
    #define CORE_US (CORE_CLOCK/1000000)                                 // the number of core clocks in a us
    register unsigned long ulPresentSystick;
    register unsigned long ulMatch;
    register unsigned long _ulDelay_us = ulDelay_us;                     // ensure that the compiler puts the variable in a register rather than work with it on the stack
    if (_ulDelay_us == 0) {                                              // minimum delay is 1us
        _ulDelay_us = 1;
    }
    (void)SYSTICK_CSR;                                                   // clear the SysTick reload flag
    ulMatch = (SYSTICK_CURRENT - CORE_US);                               // next 1us match value (SysTick counts down)
    do {
        while ((ulPresentSystick = SYSTICK_CURRENT) > ulMatch) {         // wait until a us period has expired
            if ((SYSTICK_CSR & SYSTICK_COUNTFLAG) != 0) {                // if we missed a reload
                (void)SYSTICK_CSR;
                break;                                                   // assume a us period expired
            }
        }
        ulMatch = (ulPresentSystick - CORE_US);
    } while (--_ulDelay_us != 0);
}

This assumes that the SYSTICK is running but allows it to be shared with a SYSTICK periodic interrupt.

Regards

Mark

961 Views
john71
Senior Contributor I

Thank you.

0 Kudos