lpcware

LPC1769 SystickTimer

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by sostomariano on Fri May 09 20:11:34 MST 2014
Hi there , im trying to make a simple program using Systick Timer. I want to make the Led (P0.22 ) to turn ON/OFF each 5 seconds. That means , 5 seconds ON -> 5 seconds OFF -> 5 seconds ON->.....

Im not quite sure I'm understanding how the systick works. I made a void Systick_Init(void) function to initialize the systick.

void SystickInit(void)
{
STRELOAD = (STCALIB)-1;
STCURR = 0;
ENABLE = 1;
TICKINT = 1;
CLKSOURCE = 1;

}

The thing is, i put a certain value in STRELOAD, and the lpc is going to decrease 1 unit each 10 ms , so if i put for example the value 500 in STRELOAD , it would take 5 seconds to reach the value 0 , and when it does the bit COUNTFLAG turns 1 and call the Handler function, is it that way how it works ?
I made a .c file in which i put the function initializer and the Handler , which header files do i have to include ?

void Systick_Handler(void)
{
if( COUNTFLAG == 1 )
{
COUNTFLAG = 0; // clear interrupt
SetPin(0,22,~GetPin(0,22));
}
}

Outcomes