diff options
author | Keith Packard <keithp@keithp.com> | 2009-06-17 13:55:23 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2009-06-17 13:55:23 -0700 |
commit | e59520e343c2573b1b92c0b3c4aaa93e51bc55d3 (patch) | |
tree | ccea22a92c7a2a403761139a3565da2ae22d5065 /src/ao_timer.c | |
parent | 1c3cc12c08ddefbd6456a55c54ef87dd94d4ae9a (diff) |
Fix clock initialization to not try to use 32kHz xtal on P2_3/P2_4
None of our boards have a 32kHz xtal oscillator, instead we use those pins
(on Telemetrum) for the deployment firing circuits. The old clock
initialization code was switching from the 32kHz RC oscillator to the 32kHz
crystal and overriding our use of those pins.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/ao_timer.c')
-rw-r--r-- | src/ao_timer.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ao_timer.c b/src/ao_timer.c index 81c3b376..78c6e063 100644 --- a/src/ao_timer.c +++ b/src/ao_timer.c @@ -83,3 +83,24 @@ ao_timer_init(void) /* enable timer 1 in module mode, dividing by 8 */ T1CTL = T1CTL_MODE_MODULO | T1CTL_DIV_8; } + +/* + * AltOS always cranks the clock to the max frequency + */ +void +ao_clock_init(void) +{ + /* Switch system clock to crystal oscilator */ + CLKCON = (CLKCON & ~CLKCON_OSC_MASK) | (CLKCON_OSC_XTAL); + + while (!(SLEEP & SLEEP_XOSC_STB)) + ; + + /* Crank up the timer tick and system clock speed */ + CLKCON = ((CLKCON & ~(CLKCON_TICKSPD_MASK | CLKCON_CLKSPD_MASK)) | + (CLKCON_TICKSPD_1 | CLKCON_CLKSPD_1)); + + while ((CLKCON & (CLKCON_TICKSPD_MASK|CLKCON_CLKSPD_MASK)) != + (CLKCON_TICKSPD_1 | CLKCON_CLKSPD_1)) + ; +} |