PIC32MK1024MCF100 crystal oscillator initialization
I'm slogging my way through a bunch of datasheets trying to figure out how to configure system clock with an external crystal. My ultimate goal is to have 120MHz system clock with the minimum amount of jitter. I'm not using the USB. I'm using a regular old surface mount 2 pin external crystal with a 20pF load capacitance. I'm using 2 load capacitors that are 30pF. I don't know what MHz the crystal should be yet. The clock initialization is so much more complicated on this chip than on the dsPIC30F family.
Here's where I am so far:
I have no idea what the POSCGAIN should be (3 is highest, 0 is lowest). The default is 3. So maybe that's good?
Can I just do "clock switch disabled, fail safe clock mode disabled" if I am using an external crystal, or must I start with the internal oscillator and switch to the external crystal at startup?
Should I "boost the kickstart of the oscillator"? LOL. There's no information in any datasheet that I've seen about POSCBOOST. I'm fine with a relatively slow startup. I don't want to do anything weird. I always have the code just sit there and do nothing for a few hundred milliseconds at startup anyway.
So, let's say I pick a 10MHz external crystal. So, the first thing that happens is, I set PLLIDIV to 1. so, it's still 10MHz and in the range of 5-64MHz. Next, I choose FPLLRNG = "8-16MHz". Now, I can do FPLLMULT = 48, and FPLLODIV = 4, and you get SPLL = 120MHz. OK.
Now, for the ADCs, I CANNOT set REFCLKx to SPLL, because SPLL is 120MHz, and REFCLKx input must be <= 50MHz. So, I could set REFCLKx to POSC. So, I guess this is why I would choose a higher POSC in the first place...
Then, you can use SPLL for the SYSCLK, and from that you get the clock for all the timers and PWM.