aboutsummaryrefslogtreecommitdiffstats
path: root/src/lpc176x/timer.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-10-18 09:37:47 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-10-18 09:37:47 -0400
commit8fca90844524993feb8f9dc7cfc4586ac86f2fb5 (patch)
tree496dfb5552c9aec38b18071e4e329fb712f3300a /src/lpc176x/timer.c
parent0079311b0bb23aed886c5673a6dbef13a8f35317 (diff)
downloadkutter-8fca90844524993feb8f9dc7cfc4586ac86f2fb5.tar.gz
kutter-8fca90844524993feb8f9dc7cfc4586ac86f2fb5.tar.xz
kutter-8fca90844524993feb8f9dc7cfc4586ac86f2fb5.zip
lpc176x: Divide system clock within timer; not on system bus
Scaling the timer on the system bus has a notable impact on performance. So, scale the timer within the timer hardware itself. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/lpc176x/timer.c')
-rw-r--r--src/lpc176x/timer.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/lpc176x/timer.c b/src/lpc176x/timer.c
index d8196329..1b966d1c 100644
--- a/src/lpc176x/timer.c
+++ b/src/lpc176x/timer.c
@@ -37,6 +37,9 @@ timer_init(void)
{
// Disable timer
LPC_TIM0->TCR = 0x02;
+ // Setup clock and prescaler (divide sys clock by 4)
+ LPC_SC->PCLKSEL0 = (LPC_SC->PCLKSEL0 & ~(0x3<<2)) | (0x1<<2);
+ LPC_TIM0->PR = 3;
// Enable interrupts
NVIC_SetPriority(TIMER0_IRQn, 2);
NVIC_EnableIRQ(TIMER0_IRQn);