|
100 | 100 | // </h>
|
101 | 101 | // </e>
|
102 | 102 | */
|
| 103 | + |
| 104 | +// 1 == IRC 12Mhz 2 == System Oscillator 12Mhz Xtal: |
103 | 105 | #define CLOCK_SETUP 1
|
| 106 | +//use PLL for IRC |
104 | 107 | #define SYSOSCCTRL_Val 0x00000000 // Reset: 0x000
|
105 | 108 | #define WDTOSCCTRL_Val 0x00000000 // Reset: 0x000
|
106 |
| -#define SYSPLLCTRL_Val 0x00000041 // Reset: 0x000 |
107 |
| -#define SYSPLLCLKSEL_Val 0x00000000 // Reset: 0x000 |
108 |
| -#define MAINCLKSEL_Val 0x00000003 // Reset: 0x000 |
109 |
| -#define SYSAHBCLKDIV_Val 0x00000001 // Reset: 0x001 |
110 |
| - |
| 109 | +#define SYSPLLCTRL_Val 0x00000041 // Reset: 0x000 MSEL=1 => M=2; PSEL=2 => 2P=8; PLLCLKOUT = (12x2) = 24MHz |
| 110 | +//#define SYSPLLCTRL_Val 0x00000004 // Reset: 0x000 MSEL=4 => M=5; PSEL=0 => 2P=2; PLLCLKOUT = (12x5) = 60MHz |
| 111 | +#define SYSPLLCLKSEL_Val 0x00000000 // Reset: 0x000 Select IRC |
| 112 | +#define MAINCLKSEL_Val 0x00000003 // Reset: 0x000 MainClock = PLLCLKOUT |
| 113 | +#define SYSAHBCLKDIV_Val 0x00000001 // Reset: 0x001 DIV=1 => SYSTEMCORECLK = 24 / 1 = 24MHz |
| 114 | +//#define SYSAHBCLKDIV_Val 0x00000002 // Reset: 0x001 DIV=2 => SYSTEMCORECLK = 60 / 2 = 30MHz |
111 | 115 | /*
|
112 | 116 | //-------- <<< end of configuration section >>> ------------------------------
|
113 | 117 | */
|
|
235 | 239 | /*----------------------------------------------------------------------------
|
236 | 240 | Clock Variable definitions
|
237 | 241 | *----------------------------------------------------------------------------*/
|
238 |
| -uint32_t SystemCoreClock = __SYSTEM_CLOCK;/*!< System Clock Frequency (Core Clock)*/ |
239 |
| - |
| 242 | +uint32_t MainClock = __MAIN_CLOCK; /*!< Main Clock Frequency */ |
| 243 | +uint32_t SystemCoreClock = __SYSTEM_CLOCK; /*!< System Clock Frequency (Core Clock)*/ |
240 | 244 |
|
| 245 | +//Replaced SystemCoreClock with MainClock |
241 | 246 | /*----------------------------------------------------------------------------
|
242 | 247 | Clock functions
|
243 | 248 | *----------------------------------------------------------------------------*/
|
@@ -268,46 +273,46 @@ void SystemCoreClockUpdate (void) /* Get Core Clock Frequency */
|
268 | 273 |
|
269 | 274 | switch (LPC_SYSCON->MAINCLKSEL & 0x03) {
|
270 | 275 | case 0: /* Internal RC oscillator */
|
271 |
| - SystemCoreClock = __IRC_OSC_CLK; |
| 276 | + MainClock = __IRC_OSC_CLK; |
272 | 277 | break;
|
273 | 278 | case 1: /* Input Clock to System PLL */
|
274 | 279 | switch (LPC_SYSCON->SYSPLLCLKSEL & 0x03) {
|
275 | 280 | case 0: /* Internal RC oscillator */
|
276 |
| - SystemCoreClock = __IRC_OSC_CLK; |
| 281 | + MainClock = __IRC_OSC_CLK; |
277 | 282 | break;
|
278 | 283 | case 1: /* System oscillator */
|
279 |
| - SystemCoreClock = __SYS_OSC_CLK; |
| 284 | + MainClock = __SYS_OSC_CLK; |
280 | 285 | break;
|
281 | 286 | case 2: /* Reserved */
|
282 |
| - SystemCoreClock = 0; |
| 287 | + MainClock = 0; |
283 | 288 | break;
|
284 | 289 | case 3: /* CLKIN pin */
|
285 |
| - SystemCoreClock = __CLKIN_CLK; |
| 290 | + MainClock = __CLKIN_CLK; |
286 | 291 | break;
|
287 | 292 | }
|
288 | 293 | break;
|
289 | 294 | case 2: /* WDT Oscillator */
|
290 |
| - SystemCoreClock = wdt_osc; |
| 295 | + MainClock = wdt_osc; |
291 | 296 | break;
|
292 | 297 | case 3: /* System PLL Clock Out */
|
293 | 298 | switch (LPC_SYSCON->SYSPLLCLKSEL & 0x03) {
|
294 | 299 | case 0: /* Internal RC oscillator */
|
295 |
| - SystemCoreClock = __IRC_OSC_CLK * ((LPC_SYSCON->SYSPLLCTRL & 0x01F) + 1); |
| 300 | + MainClock = __IRC_OSC_CLK * ((LPC_SYSCON->SYSPLLCTRL & 0x01F) + 1); |
296 | 301 | break;
|
297 | 302 | case 1: /* System oscillator */
|
298 |
| - SystemCoreClock = __SYS_OSC_CLK * ((LPC_SYSCON->SYSPLLCTRL & 0x01F) + 1); |
| 303 | + MainClock = __SYS_OSC_CLK * ((LPC_SYSCON->SYSPLLCTRL & 0x01F) + 1); |
299 | 304 | break;
|
300 | 305 | case 2: /* Reserved */
|
301 |
| - SystemCoreClock = 0; |
| 306 | + MainClock = 0; |
302 | 307 | break;
|
303 | 308 | case 3: /* CLKIN pin */
|
304 |
| - SystemCoreClock = __CLKIN_CLK * ((LPC_SYSCON->SYSPLLCTRL & 0x01F) + 1); |
| 309 | + MainClock = __CLKIN_CLK * ((LPC_SYSCON->SYSPLLCTRL & 0x01F) + 1); |
305 | 310 | break;
|
306 | 311 | }
|
307 | 312 | break;
|
308 | 313 | }
|
309 | 314 |
|
310 |
| - SystemCoreClock /= LPC_SYSCON->SYSAHBCLKDIV; |
| 315 | + SystemCoreClock = MainClock / LPC_SYSCON->SYSAHBCLKDIV; |
311 | 316 |
|
312 | 317 | }
|
313 | 318 |
|
|
0 commit comments