How to create a delay function in Keil uVision?

Arduino has a delay function (ms) to pause a program for a specific time. This is very accurate in milliseconds.

I have a delay function in C used by Keil uVision for the AT89C5131 chip:

void delay( unsigned long duration)
{
    while ( ( duration -- )!= 0);
}

This does some delay, but a long value is not exactly like Arduino.

Is there a way to create a function that works like a delay () function in Arduino?

The crystal operates at a frequency of 24 MHz.

Any help would be appreciated.

+3
source share
2 answers

If you want to do animation, this is done in Keil:

#pragma O0
void wait(volatile uint32_t cnt) {
    while(cnt--)
        _nop_();
}

http://www.keil.com/support/docs/606.htm

+1
source

, , (); , (, ) 51 MCU, , .

0

All Articles