News:

;) This forum is the property of Proton software developers

Main Menu

PIC24HJ64GP502 oscillator questions

Started by RGV250, Jun 17, 2024, 09:42 AM

Previous topic - Next topic

RGV250

Hi,
I am looking at getting a sensible oscillator configuration, IE 80mhz or so.
I had hoped to use the internal oscillator but as the microsoft designers were probably on mind bending drugs at the time they chose 7.37mhz which gives 79.xxx which as far as I can see is no use for CAN bit timing. Which beggars the question why they chose it on a device that has CAN.

So the questions.
I have some 40mhz oscillator modules so plan to use those as the primary oscillator.
Note 2 (figure 9-1) says if XT or HS modes are used an extended parallel 1M ohm must be used. Is this just for crystals as I cannot see how I could connect it to the module.

In 9.1.3 PLL configuration it mentions VCO of 100-200 and then PLLPOST of divide by 2,4,8. Looking at this I should be able to get 100mhz.
If I uses a 16mhz crystal and have PLLPRE / 2 then PLLDIV of 25 and PLLPOST / 2 or 10mhz crystal and PLLPRE /2 and PLLDIV of 40 and PLLPOST / 2 either should give 100mhz if my calculations are correct.
I also could use 4mhz with PLLPRE / 2 then PLLDIV of 100 and PLLPOST / 2 also 100mhz.

Is it better to use a slower external osc or does it not really matter, stripboard will be used initially so not the best electrical design. Mind you if I do the PCB it will probably be not much better.

Bob

tumbleweed

QuoteWhich beggars the question why they chose it on a device that has CAN.
The freq doesn't really matter... the internal osc accuracy is 2-5%, which is a bit too sloppy for use with CAN. Generally, for CAN you want to stay below 1%. That means each node should be better than 0.5%

QuoteI have some 40mhz oscillator modules so plan to use those as the primary oscillator.
For a 40MHz clock osc module (with logic-level outputs) you use EC or ECPLL mode and connect the module output to the OSC1 input. Leave OSC2 unconnected. Note 2 wouldn't apply.

RGV250

Hi,
I had not noticed the internal osc was not that accurate but it still seems an odd value to go for as other devices EG 18f25K22 is 16mhz.

Anyway it is a bit of a blow as i have just realised the modules I have are 5v and the osc pins are not 5v tolerant. looks like I have to source some 3.3v ones, digikey seem to so just looking at other stuff for free postage.

Bob

John Lawton

The dsPIC33F/PIC24H Family Reference Manual DS70216D tells more on the FRC.

https://ww1.microchip.com/downloads/en/DeviceDoc/70216D.pdf

Firstly the FRC can be trimmed using OSCTUN in steps on +/- 0.375% which might help you

Secondly the PLL has complicated arrangements allowing round number frequencies to be generated, e.g. 100-200MHz which can then be subdivided and they give a calculation for doing so.

John

trastikata

#4
Quote from: RGV250 on Jun 17, 2024, 02:45 PMAnyway it is a bit of a blow as i have just realised the modules I have are 5v and the osc pins are not 5v tolerant. looks like I have to source some 3.3v ones, digikey seem to so just looking at other stuff for free postage.

Hello Bob,

why insisting on RC oscillators? Use any cheap quartz crystal you have at hand - these should be precise enough. And as John said, the PLL in these PICs allows for variety of frequencies using the pre-scaller, PLL divider and post-scaller.


RGV250

Hi,
Quotewhy insisting on RC oscillators?
They are not RC oscillators but self contained so I do not have to worry about capacitance etc on stripboard etc at higher frequencies. https://abracon.com/Oscillators/ACHL.pdf

I will have to have a read up of that document, I am not sure I have the frame of mind as been admitted back in hospital with a repeat supraglotitis infection which is really not fun.

Bob

RGV250

QuoteThe freq doesn't really matter... the internal osc accuracy is 2-5%, which is a bit too sloppy for use with CAN. Generally, for CAN you want to stay below 1%. That means each node should be better than 0.5%
I know it would not be good for end use but I am just trying to get a simple dev board for trying. So far CAN has eluded me of the PIC24 mainly down to lack of good examples and the dreaded DMA. Also the examples I have found seem to use things that are not in the datasheet so can only assume they are embedded in the Microchip compiler.
It will be a holiday project as I will have plenty of pub time to ponder over the issues again.

Bob

trastikata

Quote from: RGV250 on Jun 17, 2024, 04:17 PMHi,
Quotewhy insisting on RC oscillators?
They are not RC oscillators but self contained so I do not have to worry about capacitance etc on stripboard etc at higher frequencies. https://abracon.com/Oscillators/ACHL.pdf

Just use recommended crystal capacitance and it will be OK. What is the typical crystal offset 25-30 ppm? How far can you pull that away with PCB capacitance and wrong caps - to 40 ppm? Still fraction of the percent - enough for CAN.

The parallel 1MOhm resistor must be there. Calculations are correct but also pay attention to the intermittent PLL frequency requirements (PLL-in and VCO), they are mentioned in the datasheet. 100 MHz Fosc, although in the allowed range for the VCO, is not in the Fosc range. I had overclocked a dsPIC but at some point it becomes unstable. Also the overclock stability will depend on environment temperature.

P.s. Get well soon.

RGV250

Hi,
I had a look at the OSCTUN and in theory I can get 7.999mhz or 8.02.
The question now is how do you check it, my thought at the moment would be to declare the device as 8mhz and use something like freqout a specified frequency and use a scope of frequency counter. Is there a better way?

Bob

John Lawton

I calculate that 0.00375% of 7.37MHz is 0.026735MHz and if I successively add that to my original 7.37MHz then I get either 7.97802500MHz or 8.00566250MHz so unless I've calculated it wrongly you can get very close to 8 MHz that way, of course assuming your original 7.37MHz is accurate :)

John

RGV250

#10
Hi John,
I did it slightly different, I worked back from the 8.2mhz setting in the datasheet and calculated how many multiples of 0.03mhz i needed to take off. Either way we get similar theoretical values which is why I am wondering on the best way to check it for real. I cannot do that for a bit as laid up in hospital.

Bob

trastikata

Quote from: RGV250 on Jun 17, 2024, 09:42 AMI had hoped to use the internal oscillator but as the microsoft designers were probably on mind bending drugs at the time they chose 7.37mhz which gives 79.xxx which as far as I can see is no use for CAN bit timing. Which beggars the question why they chose it on a device that has CAN.

This made me dig a bit and found an interesting table:

https://en.wikipedia.org/wiki/Crystal_oscillator_frequencies

Quote7.3728 - UART clock allows integer division to common baud rates up to 460,800(×16×1) or 921,600(×8×1).

trastikata

Quote from: RGV250 on Jun 17, 2024, 08:57 PMwhich is why I am wondering on the best way to check it for real.

Take a look here: 

https://protoncompiler.com/index.php/topic,1460.0.html

For your purposes the clock source can be another PIC with HPWM and crystal.