EmbeddedLab2023/SystickInterrupts/main.c

44 lines
722 B
C
Raw Permalink Normal View History

2023-09-01 20:01:51 +05:30
#include <stdint.h>
#include "tm4c123gh6pm.h"
/**
* main.c
*/
void GPIO_PORTF_Init(void);
2023-09-01 20:20:00 +05:30
void SystickHandler(void);
volatile uint32_t systick_count = 1;
2023-09-01 20:01:51 +05:30
int main(void)
{
2023-09-01 20:20:00 +05:30
GPIO_PORTF_Init();
NVIC_ST_RELOAD_R = 0x9C4;
2023-09-01 20:01:51 +05:30
NVIC_ST_CURRENT_R = 0x0;
//Enable Systick:
2023-09-01 20:20:00 +05:30
// SYST_CSR = 0x00000111 -- 0x7
NVIC_ST_CTRL_R = 0x7;
2023-09-01 20:01:51 +05:30
while(1);
}
2023-09-01 20:20:00 +05:30
void SystickHandler(void)
{
systick_count++;
if(systick_count==1000)
{
systick_count = 0;
GPIO_PORTF_DATA_R ^= 0x2;
}
}
2023-09-01 20:01:51 +05:30
void GPIO_PORTF_Init(void)
{
SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF;
GPIO_PORTF_DEN_R = 0x1F;
GPIO_PORTF_PUR_R = 0x11;
GPIO_PORTF_DIR_R = 0x0E;
}