From 169e06990e25fb9960d9f39bf8fe3ca39e021519 Mon Sep 17 00:00:00 2001 From: Abhijit Kshirsagar Date: Fri, 1 Sep 2023 20:20:00 +0530 Subject: [PATCH] Systick Interrupt Code --- SystickInterrupts/main.c | 21 +++++++++++++++----- SystickInterrupts/tm4c123gh6pm_startup_ccs.c | 4 +++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/SystickInterrupts/main.c b/SystickInterrupts/main.c index b6fbed7..8133b23 100644 --- a/SystickInterrupts/main.c +++ b/SystickInterrupts/main.c @@ -5,22 +5,33 @@ * main.c */ - void GPIO_PORTF_Init(void); +void SystickHandler(void); + +volatile uint32_t systick_count = 1; int main(void) { - NVIC_ST_RELOAD_R = 0x10; + GPIO_PORTF_Init(); + NVIC_ST_RELOAD_R = 0x9C4; NVIC_ST_CURRENT_R = 0x0; //Enable Systick: - // SYST_CSR = 0x00000101 -- 0x5 - NVIC_ST_CTRL_R = 0x5; - + // SYST_CSR = 0x00000111 -- 0x7 + NVIC_ST_CTRL_R = 0x7; while(1); } +void SystickHandler(void) +{ + systick_count++; + if(systick_count==1000) + { + systick_count = 0; + GPIO_PORTF_DATA_R ^= 0x2; + } +} void GPIO_PORTF_Init(void) diff --git a/SystickInterrupts/tm4c123gh6pm_startup_ccs.c b/SystickInterrupts/tm4c123gh6pm_startup_ccs.c index a8f43e7..53fe71e 100644 --- a/SystickInterrupts/tm4c123gh6pm_startup_ccs.c +++ b/SystickInterrupts/tm4c123gh6pm_startup_ccs.c @@ -33,6 +33,8 @@ void ResetISR(void); static void NmiSR(void); static void FaultISR(void); static void IntDefaultHandler(void); +void SystickHandler(void); + //***************************************************************************** // @@ -82,7 +84,7 @@ void (* const g_pfnVectors[])(void) = IntDefaultHandler, // Debug monitor handler 0, // Reserved IntDefaultHandler, // The PendSV handler - IntDefaultHandler, // The SysTick handler + SystickHandler, // The SysTick handler IntDefaultHandler, // GPIO Port A IntDefaultHandler, // GPIO Port B IntDefaultHandler, // GPIO Port C