Skip to content

Commit cf1104e

Browse files
committed
Allow configuring cpu frequency through board_build.f_cpu.
1 parent eb50ef2 commit cf1104e

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

system/CMSIS/system/system_LPC17xx.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -559,15 +559,17 @@ void SystemInit (void)
559559

560560
LPC_SC->CCLKCFG = 0x00000002; /* Setup CPU Clock Divider */
561561

562-
if(isLPC1769()) {
563-
LPC_SC->PLL0CFG = 0x0000000E; /* configure PLL0 */
564-
LPC_SC->PLL0FEED = 0xAA;
565-
LPC_SC->PLL0FEED = 0x55;
566-
} else {
567-
LPC_SC->PLL0CFG = 0x00010018; // 100MHz
568-
LPC_SC->PLL0FEED = 0xAA;
569-
LPC_SC->PLL0FEED = 0x55;
570-
}
562+
#if F_CPU == 120000000 && MCU_LPC1769
563+
LPC_SC->PLL0CFG = 0x0000000E; /* configure PLL0 */
564+
#elif F_CPU == 100000000
565+
LPC_SC->PLL0CFG = 0x00010018;
566+
#elif F_CPU == 96000000
567+
LPC_SC->PLL0CFG = 0x0000000B;
568+
#else
569+
#error "The configured cpu frequency is not supported"
570+
#endif
571+
LPC_SC->PLL0FEED = 0xAA;
572+
LPC_SC->PLL0FEED = 0x55;
571573

572574
LPC_SC->PLL0CON = 0x01; /* PLL0 Enable */
573575
LPC_SC->PLL0FEED = 0xAA;

0 commit comments

Comments
 (0)