Timer Query - LPC1317-64 Pin

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Timer Query - LPC1317-64 Pin

446 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by aamir ali on Fri Nov 23 00:41:14 MST 2012
I have to set timer in such a way that after interrupt is get stopped & want to start it agian when some specific condition met.
Should I write TCR = 0x03 or TCR = 0x01; in code below to start timer.

Condition comes from another interrupt & this run infinitely.

First timer timer will run fine as counter has been sync. will PCLK.
But when next timer has run second time, is it necessary again to sync. it



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
  
}


0 Kudos
Reply
0 Replies