I have a custom board with an LPC4357 208pin device with about 128K of code running USB, SPIFI, LCD, UARTs all working well. I am trying to get the RTC to work, but cannot get the 32Khz clock to pulse. I am driving the RTCX1 input with a 32Khz crystal oscillator and routed the 32Khz clock out to both a CLKOUT and a CLK_CGU_OUT0. I cannot get either output to toggle. If I select either output to IRC, both outputs toggle, so I know the port setup for the outputs is working. I can see the RTCX1 input toggling so I know the RTC clock input is there. I checked VBAT, is is showing 3.3V. I use this code near startup:
// Cycle the RTC 32Khz osc power, enable 32Khz
LPC_CREG->CREG0 = 0xf04;
LPC_CREG->CREG0 = 0xf03;
I used the debugger to confirm that the CREG0 values are correct. I've written many permutations of this, delaying bits, waiting seconds before writing, etc, but the 32K clock never toggles, and the RTC register writes always lock up the chip. I tried some experiments with the RTC Alarm, but reading or writing those registers causes the chip to lock up.
What am I missing? I've been fighting this for a week, and did a search on this forum for similar issues, but no-one else seems to have run into this.