From 37db80c336b94f3b997bfa75e87b930dcbed03dc Mon Sep 17 00:00:00 2001 From: Uttam Bhavimani Bhavimani Date: Sun, 22 Sep 2024 19:43:00 +0530 Subject: [PATCH] Update Group21_Lab06_Task1/main.c Add Systic Interrupt Handler --- Group21_Lab06_Task1/main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Group21_Lab06_Task1/main.c b/Group21_Lab06_Task1/main.c index 42c2771..e6e041e 100644 --- a/Group21_Lab06_Task1/main.c +++ b/Group21_Lab06_Task1/main.c @@ -48,3 +48,22 @@ void delay(int us) // DEFINING DELAY FUNCTION while ((STCTRL & (1 << 16)) == 0); // Wait until flag is set STCTRL &= 0x0; // Stop the timer } + +void SystickHandler(void) +{ // SysTick interrupt handler + ontime++; + if (ontime < duty) + { + GPIO_PORTF_DATA_R |= 0x02; // LED should be ON + } + else + { + GPIO_PORTF_DATA_R &= ~0x02; // LED should be OFF + } + + if (ontime >= 100) + { + ontime = 0; // Reset counter after one period + } +} +