Systick Timer On Explore M3
In this tutorial we will discuss how to configure lpc1768 systick timer for 1ms tick.
Contents
[hide]Prerequisites
Please check this tutorial for detailed explanation on inbuilt Lpc1768 RTC module.
If you are doing it for the first time, then check the below links to setup the project for generating the .bin file.
Hardware Connection
LED is Connected to pin 13 on Explore M3 board.
Code
Below is the sample code to blink the LED's with 1ms delay using systick timer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdutils.h" | |
#include "systick.h" | |
#include "gpio.h" | |
#define LED 13 | |
void myIsr(void) | |
{ | |
GPIO_PinToggle(LED); /* Toggle the LED(13) to measure the time */ | |
} | |
int main() | |
{ | |
SystemInit(); | |
GPIO_PinDirection(LED,OUTPUT); /* Configure the Led Pin as Output */ | |
SysTick_Init(); /* Initialize SysTick for 1ms(default)*/ | |
SysTick_AttachInterrupt(myIsr); /* myIsr will be called by SysTick_Handler every ms */ | |
SysTick_Start(); /* Start SysTick Timer */ | |
while(1) | |
{ | |
/* Do Nothing */ | |
} | |
} |