greatscottgadgets / libgreat

a library to help you do Great things
BSD 3-Clause "New" or "Revised" License
31 stars 25 forks source link

Implement NXP's recommended PLL setup sequence. #30

Closed martinling closed 1 year ago

martinling commented 2 years ago

This follows the sequence described in: UM10503 Rev 2.4 (Aug 2018), section 13.2.1.1, page 167

This sequence has already been used successfully in https://github.com/greatscottgadgets/hackrf/pull/1106.

The HackRF implementation uses a fixed 204 MHz configuration. In libgreat, the CPU clock configuration can be modified by redefining the weakly-linked platform_clock_source_configurations structure.

This implementation continues to support alternative CPU clock configurations, but restricts the possible CPU clock speeds to either <= 110 MHz or 180-204 MHz when running from PLL1. This is because the CPU must first run at the mid-range of 90-110 MHz for 50us before running above 110MHz, and the recommended technique of doubling the PLL to transition from the mid to high range cannot be applied for frequencies between 110 and 180 MHz.

If unsupported frequencies are specified or the PLL fails to lock, errors will be reported and the system will fall back to the internal oscillator.