void start()
{
timer_CT16B1_initialize();
while(1)
{
if(condition_match)
{
condition_match = 0;
[B][I][U[COLOR=Purple]]LPC_CT16B1->TCR = 0x01; // start timer[/COLOR][/U][/I][/B]
}
}
}
void CT16B1_IRQHandler(void)
{
LPC_CT16B1->IR = 0x01; //clear int flag by setting
}
/*
Timer 16 interrupt initializer
*/
void timer_CT16B1_initialize(void)
{
NVIC_SetPriority(CT16B1_IRQn,0);
NVIC_EnableIRQ(CT16B1_IRQn);
LPC_SYSCON->SYSAHBCLKCTRL |= GPIO_BIT_8;
LPC_CT16B1->TCR = 0x02; /* reset timer */
LPC_CT16B1->PR = 599;
//prescaler value
LPC_CT16B1->MR0 = 4800;
//Total delay = MR0 * (PR + 1) * Inst cycle , i.e 0x1c20 * (99+1) * 13.89
LPC_CT16B1->IR = 0x003f;
//disable interrupt initially
LPC_CT16B1->MCR = 0x0007;
//reset on match i.e TC will be zero, & interrupt on match & stop
}
|