From e10fba555bf09f7b1894222a556cbb8f6bf32c29 Mon Sep 17 00:00:00 2001 From: Uttam Ambappa Bhavimani Date: Sun, 22 Sep 2024 19:59:43 +0530 Subject: [PATCH] Update Group21_Lab06_Task2/main.c Add Systic interrupt handler --- Group21_Lab06_Task2/main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Group21_Lab06_Task2/main.c b/Group21_Lab06_Task2/main.c index 460ef92..0d8d1b0 100644 --- a/Group21_Lab06_Task2/main.c +++ b/Group21_Lab06_Task2/main.c @@ -44,4 +44,21 @@ void delay(int us) // DEFINING DELAY FUNCTION STCTRL |= (1 << 0) | (1 << 2); // Enable SysTick 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 + } } \ No newline at end of file