REVISION
Definition in file SYS_cpuClock.c.
#include "sys_clock.h"
Include dependency graph for SYS_cpuClock.c:

Go to the source code of this file.
Functions | |
| void | SYS_clockSetup (CLOCK_MODE eMode) |
| Function sets up system clock. | |
| UINT32 | SYS_getCPUClock (void) |
| Function returns the current CPU clock rate. | |
|
|
Function sets up system clock.
Definition at line 39 of file SYS_cpuClock.c. References CLOCK_MODE, and SYS_getCPUClock(). Referenced by SYS_kickoff(), UI_PSF_hisi(), UI_PSF_play(), UI_PSF_radio(), UI_PSF_record(), and USB_main(). 00040 {
00041 UINT32 CPU_clock;
00042
00043 // This is to remember what clock state it was.
00044 static CLOCK_MODE actvClockMode = Invalid_ClockMode;
00045
00046 if(actvClockMode == eMode)
00047 {
00048 return;
00049 }
00050
00051 CLKMD = 0xF000;
00052
00053 while(CLKMD&0x0001);
00054
00055 CLKMD = eMode;
00056
00057 // Set the system timer to a constant rate even though
00058 // the DSP clock can change.
00059 CPU_clock = (UINT32)SYS_getCPUClock();
00060
00061 // calculate the total divide ratio for the desired
00062 // system timer rate.
00063 #if 1 /* TINT rate = 1/( (1+PRD)*(1+TDDR)*tc ). TDDR is fixed to 15. */
00064 PRD = (CPU_clock / ( (UINT32)(BASE_TIMER_RATE * 16) ) ) - 1;
00065 #else
00066 PRD = (CPU_clock / ( (UINT32)(BASE_TIMER_RATE * 10) ) ) - 1;
00067 #endif
00068
00069 // restart the timer.
00070 TCR |= 0x2F;
00071
00072 // TIM_resolution, ns/tick in 11.4 format.
00073 TIM_resolution = ((UINT32)(BASE_TIMER_RATE_INV/(PRD+1))+ 0x8)>>4;
00074
00075 actvClockMode = eMode;
00076 }
|
Here is the call graph for this function:

|
|
Function returns the current CPU clock rate.
Definition at line 85 of file SYS_cpuClock.c. Referenced by SYS_clockSetup(), and SYS_delayMicrosecond(). 00086 {
00087 UINT16 Multiplier, PLLMUL, Divider;
00088 UINT16 PLLNDIV, PLLDIV;
00089
00090
00091 // Read back CLKMOD register value.
00092 PLLMUL = CLKMD >> 12;
00093
00094 PLLDIV = (CLKMD >> 11) & 0x1;
00095
00096 PLLNDIV = (CLKMD >> 1) & 0x1;
00097
00098 Divider = 1;
00099
00100 Multiplier = 1;
00101
00102 if (PLLDIV && PLLNDIV)
00103 {
00104 Multiplier = (PLLMUL & 0x01)? PLLMUL / 4 : (PLLMUL + 1) / 2;
00105 }
00106
00107 else if (!PLLNDIV)
00108 {
00109 // This is the /2 or /4 modes.
00110 Divider = (PLLMUL == 15)? 4 : 2;
00111 }
00112
00113 else
00114 {
00115
00116 if (PLLMUL != 15) Multiplier = PLLMUL + 1;
00117 }
00118
00119 return((UINT32)((UINT32)(SYSTEM_CLOCK * Multiplier)) / Divider);
00120 }
|
1.3.9.1