Society of Robots - Robot Forum
Software => Software => Topic started by: minmx on May 08, 2010, 11:33:00 AM
-
hi, i have a question: how can i put the pause inb c code?
-
in milliseconds: delay();
in microseconds: delaymicroseconds();
-
hmmm...depends...
There are some IDE that give you function like those amando96 said...but there are others that don't.
The most simple solution is something like this:
void delay(int a)
{
int i;
for (i = 0; i < a; i++)
{
_nop();
}
}
main(void)
{
....
delay(100000);
....
}
Also depends on what uC you use. The one i worh with has the _nop() function that does NOTHING, but wait for a tick. Here comes the frequency setup. But in my example, the function will delay around 1.25ms , with 80MHz frequency.
I say around, because there are others ticks lost when the compiler transforms the C code into ASM.
-
Going from what Benn said . . . what microcontroller are you using?