Update main.c

Initialize Delay Function
This commit is contained in:
Uttam Bhavimani Bhavimani 2024-10-28 23:39:29 +05:30
parent ff44507e26
commit 9b00f8ac49
1 changed files with 9 additions and 0 deletions

9
main.c
View File

@ -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
}