Update Group21_Lab06_Task1/main.c
Add Systic Interrupt Handler
This commit is contained in:
parent
3304d13223
commit
37db80c336
|
@ -48,3 +48,22 @@ void delay(int us) // DEFINING DELAY FUNCTION
|
||||||
while ((STCTRL & (1 << 16)) == 0); // Wait until flag is set
|
while ((STCTRL & (1 << 16)) == 0); // Wait until flag is set
|
||||||
STCTRL &= 0x0; // Stop the timer
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue