Clock system was missing

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@569 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2008-01-26 16:21:09 +00:00
parent 76d4673969
commit 948c8bd2d4
2 changed files with 257 additions and 250 deletions
+24 -22
View File
@@ -73,7 +73,7 @@ Z16F_FLOPTION3 = (Z16F_FLOPTION3_RESVD|Z16F_FLOPTION3_NORMAL);
* Private Functions * Private Functions
***************************************************************************/ ***************************************************************************/
#ifndef CONFIG_DEBUG #ifdef CONFIG_DEBUG
/*************************************************************************** /***************************************************************************
* System clock initialization--DEBUG. Code Using Frequency Input from * System clock initialization--DEBUG. Code Using Frequency Input from
* ZDS IDE. * ZDS IDE.
@@ -101,11 +101,11 @@ Z16F_FLOPTION3 = (Z16F_FLOPTION3_RESVD|Z16F_FLOPTION3_NORMAL);
static void z16f_sysclkinit(void) static void z16f_sysclkinit(void)
{ {
/* _DEFSRC (SCKSEL Bits 1,0) is passed to program view the .linkcmd file */
int count; int count;
int temp_oscdiv; int temp_oscdiv;
/* _DEFSRC (SCKSEL Bits 1,0) is passed to program view the .linkcmd file */
if ((getreg8(Z16F_OSC_CTL) & 0x03) != _DEFSRC) if ((getreg8(Z16F_OSC_CTL) & 0x03) != _DEFSRC)
{ {
if (_DEFSRC == 0) if (_DEFSRC == 0)
@@ -120,19 +120,17 @@ static void z16f_sysclkinit(void)
for (count = 0; count < 10000; count++); for (count = 0; count < 10000; count++);
/* Select 5.6 MHz clock */ /* Select 5.6 MHz clock (SCKSEL=0) */
putreg8(0xe7, Z16F_OSC_CTL); putreg8(0xe7, Z16F_OSC_CTL);
putreg8(0x18, Z16F_OSC_CTL); putreg8(0x18, Z16F_OSC_CTL);
putreg8(0xa0 | _DEFSRC, Z16F_OSC_CTL); putreg8(0xa0, Z16F_OSC_CTL);
} }
else if (_DEFSRC == 1)
if (_DEFSRC == 1)
{ {
/* enable (reserved) clock */ /* Enable (reserved) clock */
} }
else if (_DEFSRC == 2 )
if (_DEFSRC == 2 )
{ {
/* Enable external oscillator */ /* Enable external oscillator */
@@ -144,14 +142,13 @@ static void z16f_sysclkinit(void)
for (count = 0; count < 10000; count++); for (count = 0; count < 10000; count++);
/* select external oscillator */ /* select external oscillator (SCKSEL=2) */
putreg8(0xe7, Z16F_OSC_CTL); putreg8(0xe7, Z16F_OSC_CTL);
putreg8(0x18, Z16F_OSC_CTL); putreg8(0x18, Z16F_OSC_CTL);
putreg8(0xe0 | _DEFSRC, Z16F_OSC_CTL); putreg8(0xe0 | 2, Z16F_OSC_CTL);
} }
else if (_DEFSRC == 3)
if (_DEFSRC == 3)
{ {
/* Enable watchdog timer clock */ /* Enable watchdog timer clock */
@@ -163,11 +160,11 @@ static void z16f_sysclkinit(void)
for (count = 0; count < 10000; count++); for (count = 0; count < 10000; count++);
/* Select watch dog timer clock */ /* Select watch dog timer clock (SKCSEL=3) */
putreg8(0xe7, Z16F_OSC_CTL); putreg8(0xe7, Z16F_OSC_CTL);
putreg8(0x18, Z16F_OSC_CTL); putreg8(0x18, Z16F_OSC_CTL);
putreg8(0xb0 | _DEFSRC, Z16F_OSC_CTL); putreg8(0xb0 | 3, Z16F_OSC_CTL);
} }
} }
@@ -200,7 +197,7 @@ static void z16f_sysclkinit(void)
for (count = 0; count < 10000; count++); for (count = 0; count < 10000; count++);
} }
#else #else /* CONFIG_DEBUG */
/*************************************************************************** /***************************************************************************
* System Clock Initialization Recommended for Release Code * System Clock Initialization Recommended for Release Code
* *
@@ -212,27 +209,30 @@ static void z16f_sysclkinit(void)
static void z16f_sysclkinit(void) static void z16f_sysclkinit(void)
{ {
int count;
/* /*
* _DEFSRC (SCKSEL Bits 1,0) is passed to program from Target Settings Dialog. * _DEFSRC (SCKSEL Bits 1,0) is passed to program from Target Settings Dialog.
* I.E. extern _Erom unsigned long SYS_CLK_SRC; * I.E. extern _Erom unsigned long SYS_CLK_SRC;
*/ */
int count;
if ((getreg8(Z16F_OSC_CTL) & 0x03) != _DEFSRC) if ((getreg8(Z16F_OSC_CTL) & 0x03) != _DEFSRC)
{ {
/* enable external oscillator */ /* Enable external oscillator */
putreg8(0xe7, Z16F_OSC_CTL); putreg8(0xe7, Z16F_OSC_CTL);
putreg8(0x18, Z16F_OSC_CTL); putreg8(0x18, Z16F_OSC_CTL);
putreg8(0xe0, Z16F_OSC_CTL); putreg8(0xe0, Z16F_OSC_CTL);
/* wait for oscillator to stabilize */ /* Wait for oscillator to stabilize */
for (count = 0; count < 10000; count++); for (count = 0; count < 10000; count++);
/* select external oscillator */ /* Select external oscillator (SCLKSEL=2) */
putreg8(0xe7, Z16F_OSC_CTL); putreg8(0xe7, Z16F_OSC_CTL);
putreg8(0x18, Z16F_OSC_CTL); putreg8(0x18, Z16F_OSC_CTL);
putreg8(0xe0 | _DEFSRC, Z16F_OSC_CTL); putreg8(0xe0 | 2, Z16F_OSC_CTL);
} }
} }
#endif /* CONFIG_DEBUG */ #endif /* CONFIG_DEBUG */
@@ -240,9 +240,11 @@ static void z16f_sysclkinit(void)
/*************************************************************************** /***************************************************************************
* Public Functions * Public Functions
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Name: z16f_clkinit * Name: z16f_clkinit
***************************************************************************/ ***************************************************************************/
void z16f_clkinit(void) void z16f_clkinit(void)
{ {
z16f_sysclkinit(); z16f_sysclkinit();
+5
View File
@@ -45,6 +45,7 @@
* External References / External Definitions * External References / External Definitions
**************************************************************************/ **************************************************************************/
xref _z16f_clkinit:EROM
xref _z16f_lowinit:EROM xref _z16f_lowinit:EROM
#ifdef CONFIG_ARCH_LEDS #ifdef CONFIG_ARCH_LEDS
xref _up_ledinit:EROM xref _up_ledinit:EROM
@@ -142,6 +143,10 @@ _z16f_reset:
ld sp, #(_near_stack+1) /* Set Stack Pointer to the top of internal RAM */ ld sp, #(_near_stack+1) /* Set Stack Pointer to the top of internal RAM */
clr fp clr fp
/* Initialize clocking */
call _z16f_clkinit
/* Initialize onboard LEDs */ /* Initialize onboard LEDs */
#ifdef CONFIG_ARCH_LEDS #ifdef CONFIG_ARCH_LEDS