Content originally posted in LPCWare by A0087717 on Sat May 31 07:46:16 MST 2014
Hi,
I am currently doing a project with a couple of features using LPC1769. For one such feature, I would need to operate my servo motor at periodic intervals. Instead of runnning a delay, I have configured to use the SysTick function. As this function provides an interrupt in ms range, I have included a variable (count) within the SysTick Handler in order to stretch the time intervals beyond the ms range.
When executed, my program functions well (can access other features of the program) till the program enters the 'if' loop in the SysTick Handler for the first time. Once entered, only the servo is activated every 5 secs; all other features are disabled. The program doesn't exit the SysTick Handler.
My initialization of the SysTick feature in the main program is as follows:
SysTick -> CTRL = 7; //enable counter and interrupt, use CPU clk
SysTick->LOAD = 999999; //value to load 10ms
My code for the handler function:
void SysTick_Handler (void)
{
SYSTICK_ClearCounterFlag(); //clear at every 10ms
count++; //counter to tally number of interrupts
if (count == 500) //loop accessed every 5s
{
count=0; /counter reset back to 0.
lot1_rotate(); //servo arm in 'open' position
Timer0_us_Wait(2000000);//servo arm in same position for 2s
lot4_rotate(); //servo arm in 'closed' position
}
}
Any suggestion for the Handler to exit when the program executes the functions within the if loop?