Content originally posted in LPCWare by NXP_Paul on Fri Aug 16 11:03:57 MST 2013
I'm not sure why the timer intervals were defined as shown in the example code, but I can tell you what you can expect if programmed with these values.
A timer loaded with SystemCoreClock/x will generate a timing internal of 1/x seconds. In the example above, the value SystemCoreClock/10 will give you a timing interval of 0.1 seconds, while SystemCoreClock/5 would give a timing interval of 0.2 seconds. You will see this way of defining a timing interval quite often in example code because it provides a very simple way of defining the timing interval, and the timer interval will remain constant even if you change the clock value.
I can only guess that the "-1" was appended to the end of the define statement since the example uses interrupts, and interrupts are triggered one clock cycle after the timer match occurs (see Figure 114 in user manual UM10360).
By default, the clock to the timers are actually divided by four (see the PCLKSEL0 and PCLKSEL1 registers in the user manual), so they aren't being clocked at SystemCoreClock, unless you change the value in the PCLKSEL registers.
Therefore, assuming a SystemCoreclock=100MHz, you would get the following:
TIMER0_INTERVAL = ((2 * (4 *(SystemCoreClock/10))) = (2 * (4 * (0.1 sec))) = 0.8 seconds, but since the clock to the timer is divided by four, the actual time interval is 3.2 seconds.
The LED will therefore blink once every 6.4 seconds.