summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZixun LI <[email protected]>2026-07-27 20:44:18 +0200
committerZixun LI <[email protected]>2026-07-27 20:44:18 +0200
commitedb4a0744a1f7ce95fac35fc2798a5dea052571d (patch)
tree8f4eb4b8e84eee283ba4e94bfc967cb70e1b0d93
parent9a4d71162ba3b317091513fb51f7bcdaf22427dd (diff)
hw/bsp/lpc43: configure safe flash timing
-rw-r--r--hw/bsp/lpc43/family.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/hw/bsp/lpc43/family.c b/hw/bsp/lpc43/family.c
index 0f3c62fef..7f0722a33 100644
--- a/hw/bsp/lpc43/family.c
+++ b/hw/bsp/lpc43/family.c
@@ -60,10 +60,21 @@ void SystemInit(void);
void SystemInit(void)
{
#if defined(__ICCARM__) && !defined(DONT_RESET_ON_RESTART)
+ __disable_irq();
+#endif
+
+ if (Chip_CREG_OnChipFlashIsPresent()) {
+ // The boot ROM configures flash for its 96 MHz clock, and debugger core
+ // resets can preserve it. Use safe timing before switching the M4 to 204 MHz.
+ Chip_CREG_SetFLASHAccess(FLASHTIM_SAFE_SETTING);
+ __DSB();
+ __ISB();
+ }
+
+#if defined(__ICCARM__) && !defined(DONT_RESET_ON_RESTART)
// A debugger restart resets the M4 core, but can leave LPC43 peripherals and
// pending interrupts active. Match the GCC startup sequence, which the IAR
// startup lacks, before the C runtime can reuse peripheral DMA memory.
- __disable_irq();
LPC_RGU->RESET_CTRL[0] = 0x10DF1000u;
LPC_RGU->RESET_CTRL[1] = 0x01DFF7FFu;
for (uint32_t i = 0; i < 8; i++) {