cancel
Showing results for 
Search instead for 
Did you mean: 

Delay function using Tim

dmatheis
Associate II
Posted on June 23, 2009 at 10:43

Delay function using Tim

2 REPLIES 2
dmatheis
Associate II
Posted on May 17, 2011 at 13:15

Hi,

I'm a Newbie using Cortex-M3 and want to define a delay function using a tim. Do you have a simple example for this issue? I'm stuck here, because I don't know how to signal my delay function, that the timer count up or down is completed. I think setting a variable in the TIMx_IRQHandler() and waiting for this setting in my delay function is not an ideal solution (do you have a better one/example code?)?

thans a lot! :D

domen2
Associate III
Posted on May 17, 2011 at 13:15

W/o any scheduling infrastructure there's not much else to do.

You could code your delay like this, so it uses less power:

void delay()

{

while (!timer_expired) {

asm volatile (''wfi''); /* or __WFI(); or whatever equivalent */

}

}