How to enable NRF52840 to use external 32MHz crystal?

Hi all,

I'm trying to get a UART connection running at 460800 bps, and it fails about 1-5% of the time, meaning that I receive less bytes than I expect. This happens a lot less when I set the speed down to 115200 bps.

I read on the datasheet that "the external crystal oscillator must be enabled to obtain sufficient clock accuracy", page 512. I am using a u-blox Nina B301 (NRF52840), and that unit has a 32MHz oscillator attached to it.

I'm looking at the registers for the clock, and I get:

TASKS_HFCLKSTART -> 0x0

TASKS_HFCLKSTOP -> 0x0

EVENTS_HFCLKSTARTED -> 0x0

HFCLKSTAT -> 0x10000

I am assuming this tells me the clock is working from the internal 64MHz oscillator, I'm not actively doing any initialisation of the clock.

I'd like to activate the 32MHz external oscillator, but I am a bit lost with Zephyr on that driver. I only set

CONFIG_CLOCK_CONTROL=y
But I don't know any other settings or how to change the registers once the system has started.
Any help is greatly appreciated!
Cheers,
Alberto
PS.: 
I'm running on Windows 11, using a J-link debugger and SDK2.5.0 on VS Code. All else seems to work well.

Related