LPC1768 TimerInterval question

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC1768 TimerInterval question

285件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by julivico on Mon Apr 01 07:54:57 MST 2013
Hi, i'm beginer with Microcontroller. I have a LPC1768.
I want to question for functione "init_timer" and variable "TimerInterval"


Quote:

uint32_t init_timer ( uint8_t timer_num, uint32_t TimerInterval )
{
  if ( timer_num == 0 )
  {
timer0_counter = 0;
LPC_TIM0->MR0 = TimerInterval;
LPC_TIM0->MCR = 3;/* Interrupt and Reset on MR0 */

NVIC_EnableIRQ(TIMER0_IRQn);
return (1);
  }
  else if ( timer_num == 1 )
  {
timer1_counter = 0;
LPC_TIM1->MR0 = TimerInterval;
LPC_TIM1->MCR = 3;/* Interrupt and Reset on MR1 */

NVIC_EnableIRQ(TIMER1_IRQn);
return (1);
  }
  return (0);
}



in main() function i have:

Quote:
init_timer( 0, TIME_INTERVAL );



i want to make an interrupt every ms. and i have found that.

Quote:
#define TIME_INTERVAL(SystemCoreClock/1000 - 1)



SystemCoreClock is 100MHz. But that isn't correct. That is too slow.
If i make with (SystemCoreClock/4/1000 - 1), than it's ok. Can someone explain me why???

Thank you very much!!!
0 件の賞賛
2 返答(返信)

247件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Apr 09 07:25:45 MST 2013
UM10360: Peripheral Clock Selection registers 0 and 1 (PCLKSEL0 -0x400F C1A8 and PCLKSEL1 - 0x400F C1AC)

PCLK_TIMER0 Peripheral clock selection for TIMER0. Default  00 = CCLK/4 :eek:

Peripherals are  using clock divider. Default setting is 4, so either you set your divider to 1 or you change your timer setup  ;)
0 件の賞賛

247件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by julivico on Tue Apr 09 05:58:35 MST 2013
no one can help me?
0 件の賞賛