From 5db6b51759fa1b2e9595a177414874fc928d5180 Mon Sep 17 00:00:00 2001 From: Karl Kurbjun Date: Wed, 7 Nov 2007 05:30:31 +0000 Subject: Get the user timer working properly consequentially fixing doom without a hack. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15510 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/tms320dm320/kernel-dm320.c | 2 +- firmware/target/arm/tms320dm320/system-dm320.c | 4 ++ firmware/target/arm/tms320dm320/timer-dm320.c | 52 +++++++++++--------------- 3 files changed, 27 insertions(+), 31 deletions(-) (limited to 'firmware/target/arm') diff --git a/firmware/target/arm/tms320dm320/kernel-dm320.c b/firmware/target/arm/tms320dm320/kernel-dm320.c index be2b14b3cb..6608aea096 100644 --- a/firmware/target/arm/tms320dm320/kernel-dm320.c +++ b/firmware/target/arm/tms320dm320/kernel-dm320.c @@ -32,7 +32,7 @@ void tick_start(unsigned int interval_in_ms) /* Setup the Prescalar (Divide by 10) * Based on linux/include/asm-arm/arch-integrator/timex.h */ - IO_TIMER1_TMPRSCL = 0x000A; + IO_TIMER1_TMPRSCL = 0x0009; /* Setup the Divisor */ IO_TIMER1_TMDIV = (TIMER_FREQ / (10*1000))*interval_in_ms; diff --git a/firmware/target/arm/tms320dm320/system-dm320.c b/firmware/target/arm/tms320dm320/system-dm320.c index c009766f21..da3b9913a2 100644 --- a/firmware/target/arm/tms320dm320/system-dm320.c +++ b/firmware/target/arm/tms320dm320/system-dm320.c @@ -169,6 +169,10 @@ void system_init(void) IO_INTC_ENTRY_TBA0 = 0; IO_INTC_ENTRY_TBA1 = 0; + + /* Turn off other timers */ + IO_TIMER2_TMMD = CONFIG_TIMER2_TMMD_STOP; + IO_TIMER3_TMMD = CONFIG_TIMER3_TMMD_STOP; /* set GIO26 (reset pin) to output and low */ IO_GIO_BITCLR1=(1<<10); diff --git a/firmware/target/arm/tms320dm320/timer-dm320.c b/firmware/target/arm/tms320dm320/timer-dm320.c index 21449ed19f..482fef9f12 100644 --- a/firmware/target/arm/tms320dm320/timer-dm320.c +++ b/firmware/target/arm/tms320dm320/timer-dm320.c @@ -32,32 +32,16 @@ void TIMER0(void) IO_INTC_IRQ0 |= 1< 1024; prescaler >>= 1, divider++); + /* Increase prescale values starting from 0 to make the cycle count fit */ + while(divider>65535 && prescaler<1024) + { + prescaler++; + divider=cycles/(prescaler+1); + } - /* Setup the Prescalar */ IO_TIMER0_TMPRSCL = prescaler; - - /* Setup the Divisor */ IO_TIMER0_TMDIV = divider; set_irq_level(oldlevel); @@ -80,22 +65,29 @@ bool __timer_set(long cycles, bool start) return true; } -bool __timer_register(void) +static void stop_timer(void) { - bool retval = true; + IO_INTC_EINT0 &= ~(1<