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!!!