|
25 | 25 |
|
26 | 26 | #include <stdint.h> |
27 | 27 | #include "LPC17xx.h" |
| 28 | +#include "mbed-target-config.h" |
28 | 29 |
|
29 | 30 |
|
30 | 31 | /** @addtogroup LPC17xx_System |
|
297 | 298 | #define CLKSRCSEL_Val 0x00000001 |
298 | 299 | #define PLL0_SETUP 1 |
299 | 300 |
|
300 | | -#ifdef MCB1700 |
301 | | -# define PLL0CFG_Val 0x00050063 |
302 | | -# define PLL1_SETUP 1 |
303 | | -# define PLL1CFG_Val 0x00000023 |
304 | | -# define CCLKCFG_Val 0x00000003 |
305 | | -# define USBCLKCFG_Val 0x00000000 |
| 301 | +// If in 120MHz mode, clock the PLL at 480MHz as this is the only frequency that can give us both 120MHz for the core |
| 302 | +// and 48MHz for USB. |
| 303 | +#ifdef MBED_CONF_TARGET_LPC17XX_CORE_CLK_120MHZ |
| 304 | + // Multiplier for PLL0. Example: if MBED_CONF_TARGET_LPC17XX_XTAL_FREQ is 6MHz, this will be 40 |
| 305 | +# define PLL0_MULTIPLIER (240000000/MBED_CONF_TARGET_LPC17XX_XTAL_FREQ) |
| 306 | +# define PLL0CFG_Val (PLL0_MULTIPLIER-1) // PLL0 clock = <input clock> * <PLL0 multiplier> * 2 / 1 = 480MHz |
| 307 | +# define CCLKCFG_Val 0x00000003 // CPU clock = PLL0 clock / 4 = 120MHz |
| 308 | + |
| 309 | +# define USBCLKCFG_Val 0x00000009 // USB clock = PLL0 clock / 10 = 48MHz |
306 | 310 | #else |
307 | | -# define PLL0CFG_Val 0x0000000B |
308 | | -# define PLL1_SETUP 0 |
309 | | -# define PLL1CFG_Val 0x00000000 |
310 | | -# define CCLKCFG_Val 0x00000002 |
311 | | -# define USBCLKCFG_Val 0x00000005 |
| 311 | + // Multiplier for PLL0. Example: if MBED_CONF_TARGET_LPC17XX_XTAL_FREQ is 6MHz, this will be 24 |
| 312 | +# define PLL0_MULTIPLIER (144000000/MBED_CONF_TARGET_LPC17XX_XTAL_FREQ) |
| 313 | +# define PLL0CFG_Val (PLL0_MULTIPLIER-1) // PLL0 clock = <input clock> * <PLL0 multiplier> * 2 / 1 = 288MHz |
| 314 | +# define CCLKCFG_Val 0x00000002 // CPU clock = PLL0 clock / 3 = 96MHz |
| 315 | + |
| 316 | +# define USBCLKCFG_Val 0x00000005 // USB clock = PLL0 clock / 6 = 48MHz |
312 | 317 | #endif |
313 | 318 |
|
| 319 | +// Don't enable PLL1. It is much more limited in input frequency and only acceps 10-24MHz. |
| 320 | +#define PLL1_SETUP 0 |
| 321 | +#define PLL1CFG_Val 0x00000000 |
| 322 | + |
314 | 323 | #define PCLKSEL0_Val 0x00000000 |
315 | 324 | #define PCLKSEL1_Val 0x00000000 |
316 | 325 | #define PCONP_Val 0x042887DE |
|
402 | 411 | /*---------------------------------------------------------------------------- |
403 | 412 | Define clocks |
404 | 413 | *----------------------------------------------------------------------------*/ |
405 | | -#define XTAL (12000000UL) /* Oscillator frequency */ |
406 | | -#define OSC_CLK ( XTAL) /* Main oscillator frequency */ |
| 414 | +#define OSC_CLK MBED_CONF_TARGET_LPC17XX_XTAL_FREQ /* Main oscillator frequency */ |
407 | 415 | #define RTC_CLK ( 32000UL) /* RTC oscillator frequency */ |
408 | 416 | #define IRC_OSC ( 4000000UL) /* Internal RC oscillator frequency */ |
409 | 417 |
|
|
0 commit comments