Update main.c

Initialize Systick setting
This commit is contained in:
Uttam Bhavimani Bhavimani 2024-10-28 23:38:37 +05:30
parent 39340ea11f
commit ff44507e26
1 changed files with 7 additions and 0 deletions

7
main.c
View File

@ -9,3 +9,10 @@
#define CLKINT (1 << 2) // Bit 2 of CSR to specify CPU clock
#define CLOCK_HZ 16000000 // Clock frequency of EK-TM4C123GXL
#define SYSTICK_RELOAD_VALUE(us) ((CLOCK_HZ / 1000000) * (us) - 1) // SysTick reload value in microseconds based on clock frequency
void systick_setting(void)
{
STRELOAD = SYSTICK_RELOAD_VALUE(1000); // RELOAD VALUE FOR 1ms
STCTRL |= ENABLE | CLKINT; // Enable SysTick with system clock
STCURRENT = 0; // Clear current value
}