Add Systick initialization

This commit is contained in:
Sanyog Nevase Nevase 2024-10-10 20:09:42 +05:30
parent 9eb0cee283
commit faf02b4cdd
1 changed files with 16 additions and 5 deletions

21
main.c
View File

@ -39,10 +39,6 @@ void GPIO_PORT_B_init(void)
}
void UART1_WRITE(char data)
{
while (UART1_FR_R & 0x20); // Wait until TX FIFO is not full
@ -55,6 +51,20 @@ char UART1_READ(void)
return (char)UART1_DR_R; // Return received data
}
#define STCTRL *((volatile uint32_t *) 0xE000E010) // control and status
#define STRELOAD *((volatile uint32_t *) 0xE000E014) // reload value
#define STCURRENT *((volatile uint32_t *) 0xE000E018) // current value
#define CLOCK_HZ 16000000 // CLOCK FREQUENCY OF EK-TM4C123GXL
#define SYSTICK_RELOAD_VALUE(us) ((CLOCK_HZ / 1000000) * (us) - 1) // SYSTICK RELOAD VALUE
void systick_setting(void) // SYSTICK SETUP FUNCTION
{
STRELOAD = SYSTICK_RELOAD_VALUE(1000); // RELOAD VALUE FOR 1ms
STCTRL |= (1 << 0) | (1 << 2); // Enable SysTick with system clock
STCURRENT = 0; // Clear current value
}
void GPIOF_interruptHandler(void) // Interrupt handler for GPIO Port F
@ -85,7 +95,8 @@ void GPIOF_interruptHandler(void) // Interrupt handler for GPIO Po
int main(void) // MAIN FUNCTION
{
GPIO_PORT_F_init(); // GPIO INITIALISATION FUNCTION
GPIO_PORT_B_init();
systick_setting(); // SYSTICK SETUP
while (1)
{
}