Skip to content

Commit 70b3531

Browse files
committed
mb9bf560l moved pll checks inside conditon if the pll is enabled
1 parent d55a53a commit 70b3531

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

targets/core/cypress/mb9bf560l/system.hpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,15 @@ namespace klib::core::mb9bf560l::io::system {
127127
}
128128
}
129129

130-
// check if we need to configure the pll
131-
if constexpr (Multiplier > 1) {
130+
// check if we should enable the pll
131+
if constexpr (Pll == pll::pll) {
132132
static_assert(Multiplier > 0 && Multiplier < (0x3f + 1), "Invalid multiplier");
133133
static_assert(Div > 0 && Div <= (0xf + 1), "Invalid divider");
134134
static_assert(Source == source::main, "PLL is only supported for the main oscillator");
135135

136+
// calculate the frequency we are gonna run at
137+
constexpr static uint32_t freq = (Freq * Multiplier) / Div;
138+
136139
// configure the PLL
137140
CRG->PSW_TMR = 0x00;
138141

@@ -149,16 +152,10 @@ namespace klib::core::mb9bf560l::io::system {
149152
while (!(CRG->SCM_STR & (0x1 << 4))) {
150153
// do nothing
151154
}
152-
}
153-
154-
// check if we need to switch the clock switch to
155-
if constexpr (Pll == pll::pll) {
156-
// calculate the frequency we are gonna run at
157-
constexpr static uint32_t freq = (Freq * Multiplier) / Div;
158155

159-
// we have a pll. Make sure the internal clocks
160-
// are not to high. Add a prescaler if they are
161-
// above 80 mhz (needed for apbc 0/2 and wdt)
156+
// make sure the internal clocks are not to high. Add
157+
// a prescaler if they are above 80 mhz (needed for
158+
// apbc 0/2 and wdt)
162159
if constexpr (freq >= 80'000'000) {
163160
// calculate the divider required to go below 80mhz
164161
constexpr uint8_t divider = calculate_divider_80mhz<freq>();

0 commit comments

Comments
 (0)