This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F413: tickDelay

Part Number: MSP430F413

how to calculate tickDelay function need clear explanation and reference document and sample code  

if (standard)
{
// Standard Speed
// why multiplication needed and why not used single multiplied value

A = 6 * 4;
B = 64 * 4;
Cd = 60 * 4;
D = 10 * 4;
E = 9 * 4;
F = 55 * 4;
G = 0;
H = 480 * 4;
I = 70 * 4;
J = 410 * 4;
}
else
{
// Overdrive Speed
A = 1.5 * 4;
B = 7.5 * 4;
Cd = 7.5 * 4;
D = 2.5 * 4;
E = 0.75 * 4;
F = 7 * 4;
G = 2.5 * 4;
H = 70 * 4;
I = 8.5 * 4;
J = 40 * 4;
}
}

  • I give up. Did the author of this code explain what it does?

    My first guess is that it's an attempt to do a time delay using a "known" time to do multiplication. Looking at the code, though, I expect the compiler would collapse this into pretty much nothing, so it's anyone's guess how long it will delay on any given day.

    If you're trying to do a delay, I suggest __delay_cycles(), which is calibrated and predictable, and immune to the optimizer.

  • Hey G1,

    Unfortunately I'm not sure what this is either.  Do you have any more information on this function or what you are needing to do?   

    The __delay_cycles() that Bruce mentioned is probably your best option for just delaying a fixed number of clock cycles.  

    Thanks,

    JD

**Attention** This is a public forum