Add Systick initialization
This commit is contained in:
parent
9eb0cee283
commit
faf02b4cdd
21
main.c
21
main.c
|
@ -39,10 +39,6 @@ void GPIO_PORT_B_init(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UART1_WRITE(char data)
|
void UART1_WRITE(char data)
|
||||||
{
|
{
|
||||||
while (UART1_FR_R & 0x20); // Wait until TX FIFO is not full
|
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
|
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
|
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
|
int main(void) // MAIN FUNCTION
|
||||||
{
|
{
|
||||||
GPIO_PORT_F_init(); // GPIO INITIALISATION FUNCTION
|
GPIO_PORT_F_init(); // GPIO INITIALISATION FUNCTION
|
||||||
|
GPIO_PORT_B_init();
|
||||||
|
systick_setting(); // SYSTICK SETUP
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue