diff --git a/main.c b/main.c index f2ae194..74bc853 100644 --- a/main.c +++ b/main.c @@ -16,3 +16,12 @@ void systick_setting(void) STCTRL |= ENABLE | CLKINT; // Enable SysTick with system clock STCURRENT = 0; // Clear current value } + +void delay(int us) +{ + STRELOAD = SYSTICK_RELOAD_VALUE(us); // RELOAD VALUE FOR REQUIRED DELAY + STCURRENT = 0; // Clear STCURRENT + STCTRL |= ENABLE | CLKINT; // Enable SysTick + while ((STCTRL & (1 << 16)) == 0); // Wait until flag is set + STCTRL &= ~ENABLE; // Stop the timer +} \ No newline at end of file