Hello Alice,
I would like to share a root cause I discovered after spending time debugging a MemManage Fault issue on the LPC4078.
**Problem:**
When executing the firmware on an LPC4078 MCU, the system would run normally when debugging step-by-step, but would fall into a MemFault loop when running continuously without breakpoints.
**Root Cause:**
The issue was due to missing initialization of the Flash memory access time register (`LPC_SYSCTL->FLASHCFG`). By default, this register is not configured with enough wait states for high-speed operation.
In our case, after enabling PLL and running the CPU at higher frequencies, the Flash controller was still configured with its default access time, which was insufficient. This caused the CPU to fetch instructions too quickly from Flash, resulting in a precise bus fault and subsequent MemManage Fault.
**Solution:**
We resolved the issue by properly configuring the FLASHCFG register based on the CPU clock speed:
Chip_SYSCTL_SetFLASHAccess(FLASHTIM_SAFE_SETTING);
Thank you.
Michelle