Electronic – PIC24 PLL initial value

oscillatorpicpll

I'm setting up my PIC oscillator frequency and I'm using a PIC24HJ128GP202. From what I've seen in the datasheet, two of my total options were to use a crystal or a internal oscillator (FRC) which would go through the PLL and scale my frequency of operation up to 80MHz.

I decided to use a 10MHz external crystal. To reach 40 MIPS I should configure correclty the PLL parameters N1, N2 and M. It all seems to be fine except that these last parameters are configurable by software. I was used to PIC's like PIC18f4550 where these oscillator settings were configurable through the configuration bits. So whenever I program the device, it would have those settings always after reset.

In this case (PIC24HJ128GP202) I can only configure what kind of oscillator I will use in the configuration bits (HS with PLL). PLL is only configurable by software. So, since the PLL default values will get my frequency out of the bounds specified by the datasheet, how can I configure the PLL by software if the software requires a correct oscillator frequency of operation? Is it the case of using IESO (start-up with internal oscillator)? Any other way around this problem?

Best Answer

Please refer to section 2.7 in the datasheet.

If the PLL of the target device is enabled and configured for the device start-up oscillator, the maximum oscillator source frequency must be limited to 4 MHz < FIN < 8 MHz to comply with device PLL start-up conditions. This means that if the external oscillator frequency is outside this range, the application must start-up in the FRC mode first. The default PLL settings after a POR with an oscillator frequency outside this range will violate the device operating speed.

Looks like you will have to start-up with the internal oscillator and then switch to your specific settings.