From 34d0ad34a2b0e7ddd8a403d7ca608e9a244a2512 Mon Sep 17 00:00:00 2001 From: Sanyog Date: Sun, 22 Sep 2024 20:26:32 +0530 Subject: [PATCH] add GPIO interrupt Handler --- Group21_Lab06_Task1/main.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Group21_Lab06_Task1/main.c b/Group21_Lab06_Task1/main.c index e6e041e..90792b7 100644 --- a/Group21_Lab06_Task1/main.c +++ b/Group21_Lab06_Task1/main.c @@ -67,3 +67,24 @@ void SystickHandler(void) } } +void GPIOF_interruptHandler(void) +{ + delay(200000); // Debounce delay + if (GPIO_PORTF_RIS_R & 0x01) // Check if PF0 caused the interrupt (Switch 1) + { + duty += 5; // Increase duty cycle + if (duty > 100) duty = 100; // Limit to max 100% + GPIO_PORTF_ICR_R = 0x01; // Clear interrupt flag for PF0 + // systick_setting(); + } + + if (GPIO_PORTF_RIS_R & 0x10) + { // Check if PF0 caused the interrupt (Switch 1) + duty -= 5; // Increase duty cycle + if (duty < 0) duty = 0; // Limit to max 100% + GPIO_PORTF_ICR_R = 0x10; // Clear interrupt flag for PF0 + //systick_setting(); + } + systick_setting(); +} +