1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 by Michael Sevakis
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
27 void tick_start(unsigned int interval_in_ms
)
30 * Based on default PCLK of 49.1568MHz - scaling chosen to give
31 * remainder-free result for tick interval of 10ms (100Hz)
32 * Timer input clock frequency =
33 * fPCLK / {prescaler value+1} / {divider value}
34 * TIMER_FREQ = 49156800 / 2
35 * 146300 = TIMER_FREQ / 21 / 8
36 * 49156800 = 19*11*(7)*7*5*5*(3)*2*2*2*2*2*2
42 /* Set the count for timer 4 */
43 TCNTB4
= (TIMER_FREQ
/ TIMER234_PRESCALE
/ 8) * interval_in_ms
/ 1000;
44 /* Set the the prescaler value for timers 2,3, and 4 */
45 TCFG0
= (TCFG0
& ~0xff00) | ((TIMER234_PRESCALE
-1) << 8);
46 /* DMA mode off, MUX4 = 1/16 */
47 TCFG1
= (TCFG1
& ~0xff0000) | 0x030000;
50 /* reset manual bit */
58 /* timer 4 unmask interrupts */
59 INTMSK
&= ~TIMER4_MASK
;
65 s3c_regset32(&INTMSK
, TIMER4_MASK
);
74 /* Run through the list of tick tasks */