Delay Function in MCUXpresso (like Arduino)

cancel
Showing results for 
Search instead for 
Did you mean: 

Delay Function in MCUXpresso (like Arduino)

Jump to solution
74 Views
caden013
Contributor III

Hi all,

I am just wondering if there is a delay function in the MCUXpresso IDE. For example, I am wanting to create a 1 second delay in my program, and I am wondering if there is a nice function to use instead of creating nested for loops. 

For example, in Arduino code, I would just use the function:

delay(1000);

Thanks in advance.

0 Kudos
1 Solution
69 Views
frank_meyer
Senior Contributor I

To be honest, Arduino is not the best template for professional SW development, to say the least.

Delay functions (busy idling) are one of the worst choices, better use a timer peripheral.

I used to use the SysTick timer available in all Cortex M devices. Set it up at a proper cycle (e.g. 10ms), and handle your delay functionality in the respective interrupt handler.

This way, you can run multiple different delay in parallel without interference and very little performance impact.

View solution in original post

1 Reply
70 Views
frank_meyer
Senior Contributor I

To be honest, Arduino is not the best template for professional SW development, to say the least.

Delay functions (busy idling) are one of the worst choices, better use a timer peripheral.

I used to use the SysTick timer available in all Cortex M devices. Set it up at a proper cycle (e.g. 10ms), and handle your delay functionality in the respective interrupt handler.

This way, you can run multiple different delay in parallel without interference and very little performance impact.

View solution in original post