keil_examples/timer/timer.c
/*****************************************************************************
** Function name:		delayMs
**
** Descriptions:		Start the timer delay in milo seconds
**						until elapsed
**
** parameters:			timer number, Delay value in milo second			 
** 						
** Returned value:		None
** 
*****************************************************************************/
Function name:         delayMs
Descriptions:          Start the timer delay in milo seconds
until elapsed

timer number, Delay value in milo second

Returned value:                None
Function name : delayMs Descriptions : Start the timer delay in milo seconds until elapsed timer number Delay value in milo second Returned value : None
void delayMs(uint8_t timer_num, uint32_t delayInMs)
{
  if ( timer_num == 0 )
  {
	LPC_TIM0->TCR = 0x02;		
	LPC_TIM0->PR  = 0x00;		
	LPC_TIM0->MR0 = delayInMs * (9000000 / 1000-1);
	LPC_TIM0->IR  = 0xff;		
	LPC_TIM0->MCR = 0x04;		
	LPC_TIM0->TCR = 0x01;		
	while (LPC_TIM0->TCR & 0x01);
  }
  else if ( timer_num == 1 )
  {
	LPC_TIM1->TCR = 0x02;		
	LPC_TIM1->PR  = 0x00;		
	LPC_TIM1->MR0 = delayInMs * (9000000 / 1000-1);
	LPC_TIM1->IR  = 0xff;		
	LPC_TIM1->MCR = 0x04;		
	LPC_TIM1->TCR = 0x01;		
	while (LPC_TIM1->TCR & 0x01);
  }
  return;
}
void delayMs ( uint8_t timer_num , uint32_t delayInMs ) { if ( timer_num == 0 ) { LPC_TIM0 -> TCR = 0x02 ; LPC_TIM0 -> PR = 0x00 ; LPC_TIM0 -> MR0 = delayInMs * ( 9000000 / 1000 - 1 ) ; LPC_TIM0 -> IR = 0xff ; LPC_TIM0 -> MCR = 0x04 ; LPC_TIM0 -> TCR = 0x01 ; while ( LPC_TIM0 -> TCR & 0x01 ) ; } else if ( timer_num == 1 ) { LPC_TIM1 -> TCR = 0x02 ; LPC_TIM1 -> PR = 0x00 ; LPC_TIM1 -> MR0 = delayInMs * ( 9000000 / 1000 - 1 ) ; LPC_TIM1 -> IR = 0xff ; LPC_TIM1 -> MCR = 0x04 ; LPC_TIM1 -> TCR = 0x01 ; while ( LPC_TIM1 -> TCR & 0x01 ) ; } return ; }
Function name:         delayMs
Descriptions:          Start the timer delay in milo seconds
until elapsed
Function name : delayMs Descriptions : Start the timer delay in milo seconds until elapsed
/* reset timer */ /* set prescaler to zero */ /* reset all interrrupts */ /* stop timer on match */ /* start timer */ /* wait until delay time has elapsed */ /* reset timer */ /* set prescaler to zero */ /* reset all interrrupts */ /* stop timer on match */ /* start timer */ /* wait until delay time has elapsed */