First of all are 2 clocks: one for CPU and one for USB, both clocks sometimes derived from the same external oscillator as in my case.
If we decide to use external oscillator (Primary oscillator OSC1-OSC2), particular quartz crystal, then the table on the datasheet page 32-33, first column from left tells us the value for the crystal can be used.
Nevertheless, on the page 28 it is mentioned only 4, 8 and 20MHz when different capacitors for crystal are mentioned.
The same information is found on AN849 “Basic PICmicro® Oscillator Design”.
In my case I decided for HS 20MHz crystal.
I decided to assure compatibility of USB low speed, therefore I want 24MHz for CPU speed, mentioned on page 32, chapter 2.3.1
The 24MHz is written with bold to be easy observed.
My case is page 33 the row with 20MHz using HSPLL.
Then page 145 of PIC18 Configuration Settings Addendum.
The steps are:
1) If we choose 20MHz crystal (marked A) and we want PLL, then automatically we have to choose divided by 5 for PLL DIV (marked B), because the result must be always 4MHz as it is mentioned on page 26 block diagram after PLLDIV MUX, and we have to choose HSPLL for oscillator type (marked C).
2) The we choose USBDIV=1 as bit defined on datasheet page 295 (bit 5) and marked with USBDIV=2 (marked F) on page 145 of PIC18 Configuration Settings Addendum.
3) As the result of PLL is always 96MHz then to get 24MHz for CPU clock, in order to assure compatibility of USB low speed, then we have to choose CPUDIV value 4 (marked D), because 96MHz/4=24MHz (marked E).
If we decide to use external oscillator (Primary oscillator OSC1-OSC2), particular quartz crystal, then the table on the datasheet page 32-33, first column from left tells us the value for the crystal can be used.
Nevertheless, on the page 28 it is mentioned only 4, 8 and 20MHz when different capacitors for crystal are mentioned.
The same information is found on AN849 “Basic PICmicro® Oscillator Design”.
In my case I decided for HS 20MHz crystal.
I decided to assure compatibility of USB low speed, therefore I want 24MHz for CPU speed, mentioned on page 32, chapter 2.3.1
The 24MHz is written with bold to be easy observed.
My case is page 33 the row with 20MHz using HSPLL.
Then page 145 of PIC18 Configuration Settings Addendum.
The steps are:
1) If we choose 20MHz crystal (marked A) and we want PLL, then automatically we have to choose divided by 5 for PLL DIV (marked B), because the result must be always 4MHz as it is mentioned on page 26 block diagram after PLLDIV MUX, and we have to choose HSPLL for oscillator type (marked C).
2) The we choose USBDIV=1 as bit defined on datasheet page 295 (bit 5) and marked with USBDIV=2 (marked F) on page 145 of PIC18 Configuration Settings Addendum.
3) As the result of PLL is always 96MHz then to get 24MHz for CPU clock, in order to assure compatibility of USB low speed, then we have to choose CPUDIV value 4 (marked D), because 96MHz/4=24MHz (marked E).