Skip to content

Commit 0ee115d

Browse files
authored
fix(Examples): Fix RTC and RTC_Backup Example ERFO Initialization for MAX32655 (#760)
1 parent e57fd9f commit 0ee115d

File tree

2 files changed

+5
-37
lines changed

2 files changed

+5
-37
lines changed

Examples/MAX32655/RTC/main.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -162,28 +162,10 @@ void printTime()
162162
int main(void)
163163
{
164164
int rtcTrim;
165-
volatile int i;
166-
167-
/* Delay to prevent bricks */
168-
for (i = 0; i < 0xFFFFFF; i++) {}
169-
170-
/* Set the system clock to the 32 MHz clock for the RTC trim */
171-
/* Enable 32 MHz clock if not already enabled */
172-
if (!(MXC_GCR->clkctrl & MXC_F_GCR_CLKCTRL_ERFO_RDY)) {
173-
/* Power VREGO_D */
174-
MXC_SIMO->vrego_d = (0x3c << MXC_F_SIMO_VREGO_D_VSETD_POS);
175-
while (!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYD)) {}
176-
177-
/* Restore btleldoctrl setting */
178-
MXC_GCR->btleldoctrl = 0x3055;
179-
while (!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYD)) {}
180-
181-
/* Enable 32Mhz oscillator */
182-
MXC_GCR->clkctrl |= MXC_F_GCR_CLKCTRL_ERFO_EN;
183-
while (!(MXC_GCR->clkctrl & MXC_F_GCR_CLKCTRL_ERFO_RDY)) {}
184-
}
165+
MXC_Delay(MXC_DELAY_SEC(2)); // Delay to give debugger a window to connect
185166

186167
/* Switch the system clock to the 32 MHz oscillator */
168+
MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERFO);
187169
MXC_SYS_Clock_Select(MXC_SYS_CLOCK_ERFO);
188170
MXC_SYS_SetClockDiv(MXC_SYS_CLOCK_DIV_1);
189171
SystemCoreClockUpdate();

Examples/MAX32655/RTC_Backup/main.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,10 @@ void printTime()
125125
int configureRTC()
126126
{
127127
int rtcTrim;
128-
volatile int i;
128+
MXC_Delay(MXC_DELAY_SEC(2)); // Delay to give debugger a window to connect
129129

130-
for (i = 0; i < 0xFFFFFF; i++) {}
131-
// Prevent bricks
132-
133-
if (!(MXC_GCR->clkctrl &
134-
MXC_F_GCR_CLKCTRL_ERFO_RDY)) { // Enable 32Mhz clock if not already enabled
135-
MXC_SIMO->vrego_d = (0x3c << MXC_F_SIMO_VREGO_D_VSETD_POS); // Power VREGO_D
136-
while (!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYD)) {}
137-
138-
MXC_GCR->btleldoctrl = 0x3055; // Restore btleldoctrl setting
139-
while (!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYD)) {}
140-
141-
MXC_GCR->clkctrl |= MXC_F_GCR_CLKCTRL_ERFO_EN; // Enable 32Mhz oscillator
142-
while (!(MXC_GCR->clkctrl & MXC_F_GCR_CLKCTRL_ERFO_RDY)) {}
143-
}
144-
145-
MXC_SYS_Clock_Select(MXC_SYS_CLOCK_ERFO); // Set 32MHz clock as system clock
130+
/* Switch the system clock to the 32 MHz oscillator */
131+
MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERFO);
146132
MXC_SYS_SetClockDiv(MXC_SYS_CLOCK_DIV_1);
147133
SystemCoreClockUpdate();
148134

0 commit comments

Comments
 (0)