This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How use timer to delay in a function?

A delay function is defined normally as:

void delay(int n)
{
   int i;
   for (i= 0; i<n; i++)
   _nop_();
}


when delay() performed,ALU get in loop but do nothing.Can use a timer counting to delay and release ALU to do something ?For example ,after input commands to erase I28F128 flash,enable timer0 to counting and program go do something else,when counting to 5's(flash is erased ),program go back and begin to write data to flash.

Best regards

Parents
  • "Oh dear, please don't say that something as mundane as a delay must now be classified as proper or otherwise!"

    You can argue about whether "proper" is an appropriate term for it, but it is certainly a Really Bad Idea - for precisely the reasons given (and subject to the exceptions explained) by Hans-Bernhard Broeker.

Reply
  • "Oh dear, please don't say that something as mundane as a delay must now be classified as proper or otherwise!"

    You can argue about whether "proper" is an appropriate term for it, but it is certainly a Really Bad Idea - for precisely the reasons given (and subject to the exceptions explained) by Hans-Bernhard Broeker.

Children