Question on how to calculate timer intervals on LPC2106
2004-11-29 by ©@°Ø¦â¤p¿ß
Hi, I am new to this LPC group and I would like to say 'hello' to everyone who is reading this message! Currently I am working with a LPC2106 processor and my first task is to get the LEDs on the board to blink at a correct frequency. I am using a 20MHz crystal osillator with the setting of PLL multiplier value of 3 (which gets me 60MHZ for system clock rate), a VPB divider of 2 (gets me 30MHz for pclk frequency). I am using vectored IRQ interrupts to increment the cntr (counter) in my C main() function, in order to set that: if the counter has been counted for 500 times (cntr > = 500), the LEDs would be turned on (and turned off after another 500 counts therefore it blinks by using IOSET and IOCLR). The value of Match Register on Timer0 has been set as 60000 (MR0 = 60000). So the question I want to ask is that: How do I know wether the LEDs are blinking at the correct time interval of 1 second? And if I want to make the LEDs blinking at a rate of EXACTLY 2 seconds or 1/2 seconds (or at any other frequency), how should I set the MR value or the cntr value in order to do that? Is there a formula for calculating the relationships between Match Register value and the pclk? Thank you for reading my post! ^^