1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 by Maurus Cuelenaere
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
)
33 __tcu_stop_counter(0);
34 __tcu_disable_pwm_output(0);
36 __tcu_mask_half_match_irq(0);
37 __tcu_unmask_full_match_irq(0);
39 __tcu_select_extalclk(0);
40 __tcu_select_clk_div4(0);
42 /* 12Mhz / 4 = 3Mhz */
43 latch
= interval_in_ms
*1000 * 3;
46 REG_TCU_TDFR(0) = latch
;
47 REG_TCU_TDHR(0) = latch
;
49 __tcu_clear_full_match_flag(0);
50 __tcu_start_counter(0);
52 system_enable_irq(IRQ_TCU0
);
55 /* Interrupt handler */
58 __tcu_clear_full_match_flag(0);
60 /* Run through the list of tick tasks */