From faf02b4cdd364f25339e761e304c8faeb68c3d55 Mon Sep 17 00:00:00 2001 From: Sanyog Date: Thu, 10 Oct 2024 20:09:42 +0530 Subject: [PATCH] Add Systick initialization --- main.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index b89fee8..191f656 100644 --- a/main.c +++ b/main.c @@ -39,10 +39,6 @@ void GPIO_PORT_B_init(void) } - - - - void UART1_WRITE(char data) { while (UART1_FR_R & 0x20); // Wait until TX FIFO is not full @@ -55,6 +51,20 @@ char UART1_READ(void) return (char)UART1_DR_R; // Return received data } +#define STCTRL *((volatile uint32_t *) 0xE000E010) // control and status +#define STRELOAD *((volatile uint32_t *) 0xE000E014) // reload value +#define STCURRENT *((volatile uint32_t *) 0xE000E018) // current value + +#define CLOCK_HZ 16000000 // CLOCK FREQUENCY OF EK-TM4C123GXL +#define SYSTICK_RELOAD_VALUE(us) ((CLOCK_HZ / 1000000) * (us) - 1) // SYSTICK RELOAD VALUE + +void systick_setting(void) // SYSTICK SETUP FUNCTION +{ + STRELOAD = SYSTICK_RELOAD_VALUE(1000); // RELOAD VALUE FOR 1ms + STCTRL |= (1 << 0) | (1 << 2); // Enable SysTick with system clock + STCURRENT = 0; // Clear current value +} + void GPIOF_interruptHandler(void) // Interrupt handler for GPIO Port F @@ -85,7 +95,8 @@ void GPIOF_interruptHandler(void) // Interrupt handler for GPIO Po int main(void) // MAIN FUNCTION { GPIO_PORT_F_init(); // GPIO INITIALISATION FUNCTION - + GPIO_PORT_B_init(); + systick_setting(); // SYSTICK SETUP while (1) { }