Content originally posted in LPCWare by pierre on Thu Aug 28 01:06:35 MST 2014
There are still some issues...
In LPX4330 Xplorer board_sysinit.c, function Board_SetupClocking() :
Chip_SetupCoreClock(CLKIN_CRYSTAL, MAX_CLOCK_FREQ, true);
If i set it to CLKIN_IRC, it works.
If I set it to crystal, it does not work, the cpu stops responding even to JTAG. Then I have to use the boot mode switches to prevent it to boot from SPIFI and execute the offending code in order to use LPC-Link to reflash a working code (which uses the IRC oscillator).
This is a symptom of incorrect clock initialization I guess. Maybe it doesn't wait enough for the oscillator to start ?...
However, after booting on the IRC oscillator, if I put "Chip_SetupCoreClock(CLKIN_CRYSTAL, MAX_CLOCK_FREQ, true);" in main(), then, it works. This is quite bizarre. Does it actually use the XTAL or the IRC, I wonder...
Also, I'd like to use a lower clock frequency to consume less power. If I replace MAX_CLOCK_FREQ with 120 MHz, it works, and the frequency seems to be correct. With a frequency below 110000000, it does not work : depending on the values, either the cpu freezes, or it kind of works but the UART output is garbled. I think it is because of this line in lpcopen sysinit_18xx_43xx.c / Chip_SetupCoreClock() :
if (core_freq > 110000000UL)
It configures the PLL differently depending on the frequency.
However it only wants to go up : the code is there to go from the default (low) boot frequency to 204 MHz, but the code is not there to go the other way around !...
So, I change Board_SetupClocking to startup at 96 MHz. No more problems. Except the UART stops working, probably because it uses the wrong baud rate (which should be set automatically by Chip_UART_SetBaud() according to the CPU freq but it seems it is not...
Hm...