Systick Interrupt Code

This commit is contained in:
Abhijit Kshirsagar Kshirsagar 2023-09-01 20:20:00 +05:30
parent 211c555186
commit 169e06990e
2 changed files with 19 additions and 6 deletions

View File

@ -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)

View File

@ -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