From 9b00f8ac493535edabfa5c16182caf46601ef37a Mon Sep 17 00:00:00 2001 From: Uttam Ambappa Bhavimani Date: Mon, 28 Oct 2024 23:39:29 +0530 Subject: [PATCH] Update main.c Initialize Delay Function --- main.c | 9 +++++++++ 1 file changed, 9 insertions(+) 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