Hi, Eli,
Regarding the snippet of code, I think it is okay if you increase the delay as 100 000, it just waits for the stabilization of the crystal.
Hope it can help you
BR
XiangJun rong
/* Enables the crystal oscillator */
void Chip_Clock_EnableCrystal(void)
{
volatile uint32_t delay = 1000;
uint32_t OldCrystalConfig = LPC_CGU->XTAL_OSC_CTRL;
/* Clear bypass mode */
OldCrystalConfig &= (~2);
if (OldCrystalConfig != LPC_CGU->XTAL_OSC_CTRL) {
LPC_CGU->XTAL_OSC_CTRL = OldCrystalConfig;
}
/* Enable crystal oscillator */
OldCrystalConfig &= (~1);
if (OscRateIn >= 20000000) {
OldCrystalConfig |= 4; /* Set high frequency mode */
}
LPC_CGU->XTAL_OSC_CTRL = OldCrystalConfig;
/* Delay for 250uSec */
while(delay--) {}
}