Content originally posted in LPCWare by lpcxpresso-support on Fri Aug 29 22:22:49 MST 2014
A few observations about your new_milestone project.
1. I think there's a bit of confusion on how you use LPCOpen. In your compile, you use the __USE_LPCOPEN define to link in LPCOpen code which ultimately sets your cpu core frequency to the a maximum frequency of 204 MHz based on the IRC. Later, in your main routine, you reset the cpu core frequency to 50 MHz (actual 48 MHz) based on the external crystal. I notice you're bypassing the board library, which you could leverage for setting up pin muxing among other things. You should decide on a way forward here.
2. In your main routine, the SystemCoreClockUpdate call is setting your SystemCoreClock variable to 12 MHz. I think you want to display the cpu core frequency here. The SystemCoreClock variable does not reflect the value I think you're after. I don't claim to understand the operation of this call, but perhaps I can find more information for you.
Note the reason I focus on clock setup, is an unstable clock/PLL can affect the operation (and debug operation) of the part. Anytime you encounter a fatal error while connecting a debug session (e.g. "Ep(04). Cannot halt processor."), open the process list and kill the following processes, if present:
redlinkserv.exe
arm_none_eabi_gdb.exe
crt_emu_cm_redlink.exe
There's also a feature within the Redlink Server console to kill the existing server process.
Finally, erase the flash and cycle power.
3. I'm not able to debug your new_milestone project as delivered. It takes a hardfault. I tested your project running from SPIFI flash on an LPC-Link2 board which utilizes an LPC4370. The Winbond SPIFI flash is an 8 M-bit flash device, so I had to modify the mm06_uart_Debug_mem.ld script.
Here's a list of the changes I made.
1. In clock_18xx_43xx.h, define MAX_CLOCK_FREQ 50000000.
2. In Chip_SystemInit (sysinit_18xx_43xx.c), replace the call to Chip_SetupIrcClocking with Chip_SetupXtalClocking. The chip library now configures your cpu core frequency to 50 MHz using the external crystal and main PLL.
3. In main, replace the call to Chip_Clock_SetupMainPLL_mch, and SystemCoreClockUpdate with the following:
SystemCoreClock = Chip_Clock_GetMainPLLHz(); // I think this is what you want
4. Configure all RAM breakpoints in your list as hardware breakpoints if these breaks exist in the break list prior to starting the debug session.
Regards,
LPCXpresso-Support