Program to determine Xtal Frequency - please try this for me :)
Cluso99
Posts: 18,069
Attached is a binary that should hopefully self-determine the crystal frequency and mode.
I am not sure whether this will always work due to the die process variations but its worth testing it out.
I am trying to determine crystals from 5.00MHz to 7.00MHz stepping every 0.25MHz, and 7.00MHz to 14.00MHz stepping every 0.5MHz.
I don't have all these crystals but with what I have it works, and I have extrapolated the others.
There is a 2s delay before the program runs to give you time to open up a serial terminal after downloading the program.
Here is a sample of what to expect.
If it woks, I will tidy and post the code
I am not sure whether this will always work due to the die process variations but its worth testing it out.
I am trying to determine crystals from 5.00MHz to 7.00MHz stepping every 0.25MHz, and 7.00MHz to 14.00MHz stepping every 0.5MHz.
I don't have all these crystals but with what I have it works, and I have extrapolated the others.
There is a 2s delay before the program runs to give you time to open up a serial terminal after downloading the program.
Here is a sample of what to expect.
FindFreq: Test the crystal frequency v0.10 *** Found Clock 104000000Hz, mode $6F, Crystal 6500000Hz, (116,219) FindFreq: Test the crystal frequency v0.10 *** Found Clock 104000000Hz, mode $6F, Crystal 6500000Hz, (115,219) FindFreq: Test the crystal frequency v0.10 *** Found Clock 96000000Hz, mode $6E, Crystal 12000000Hz, (211,0)
If it woks, I will tidy and post the code
Comments
Do you mean determine the crystal band grouping, for automatic correct VCO Divsion selection ?
as in ...
5MHz region Xtals use (Xtal x 16) / 1 -> SysCLK
10MHz region Xtals use (Xtal x 16) / 2 -> SysCLK
If you want to test something with *any* crystal value, I've found the Si5351A breakout from Adafruit useful.
It can output 3 different clocks to high precision, per program record sent via i2c.
Thanks for this. The range I have set for 5MHz is 160-169 where 170-179 is in my 5.25MHz range.
I need to see some more results to see if I can trim the ranges better, otherwise it is not going to work.
jmg,
Yes, I want to see how much variation there is between different dice.
Variable clock chips will not help here.
I'm not quite following ?
There will be significant variations between dice, and also with Vcc and Temperature of the VCO limits, so I would call 5.25MHz for a 5.00Mhz value actually quite good.
The best you can hope for is something like a '5MHz or 10Mhz' decision,
The VCO divide choices are only 2:1 anyway, so there seems not much need to be a lot finer ?
If you need much finer than that, you could get that from a BYTE received, for example.
On my G/G Propeller Platform
I am attempting to make my PropOS device and xtal independant so that I can release one binary for all prop/xtal sets (within a reasonable range). Here I often swap xtals. I can already detect all my pcb hardware so it shouldn't be hard to detect other common hardware. I am trying to avoid the alternative of auto-bauding on every power up (I have done this).
Btw the two results at the end of the message are clock count averages. If the second one is zero then you have a xtal operating at pll16x. (Over ~8MHz). If the second one is not zero then you are operating with pll8x and the first count should be ~162.
Anyone with a 6.25MHz or 10MHz xtal I would like to see what you get. I couldn't find all my box of xtals
Thanks
I do have my doubts that I can make this work successfully, but it is definitely worth trying it out as the benefits would be too good to pass up.
The only timing reference available that is common to all systems that I know of is the serial port used by the bootloader. Turn on the crystal without PLL perhaps and send a CR at 115200 baud and bingo!
The question is one of precision - With chip process variation, and away from the corners of extreme Vcc or Temperature, you should be able to decide 5MHz or 10MHz, but it is not clear exactly what precision the OP expects, or what 'work successfully' means ?
Trying to resolve between 5.25MHz or 5MHz with a free running, uncalibrated oscillator, I would call optimistic.
Using PC baud as calibrate, should resolve to under 1% at lowish baud rates on RC based bridges, and probably under 100ppm is possible on crystal based bridges.
eg We've done RC Calibrate sweeps on Silabs devices with a 15ppm LSB using a crystal based UART, but that's somewhat excessive precision as I was also looking at noise and jitter.
For example, there are a few base frequencies we use:
5, 6, (6.25), 6.5, 10, 12, (13.5) MHz.
Phils code can already determine the difference below 10MHz and equal/above.
While checking out his code I discovered some details about the pll in the counters. It seems that even with 5MHz & pllx16 the counter pll is not precise. However there is a range that it operates on. This range varies with xtal frequency.
Hence my effort to use this phenonom to see if I can reliably detect some different xtals, and how much process variations effect this.
BTW any xtals below about 8MHz with pll8 all lock successfully returning 162+/-1 and above 8MHz with pllx4 return the same.
I am only interested in general usage, not different voltages, etc.
If this works, auto-bauding will not be necessary. And what if the and keyboard are used and no serial where auto-baud img won't be available.
To resolve between 6.25MHz and 6.00 MHz is a ratio of
4%, so you expect/require the chip spreads to be better than 4%.
To me, that is (very) unlikely.
Even if it doesn't work for you (wrong baud giving rubbish).
Propeller Professional Development Board (5MHz Xtal)
FindFreq: Test the crystal frequency v0.10
*** Found Clock 84000000Hz, mode $6F, Crystal 5250000Hz, (116,171)
*** Found Clock 80000000Hz, mode $6F, Crystal 5000000Hz, (116,167)
Also, I was trying to figure out how I would go about this, and I have one idea, but it does require a pin. I could probably use the i2c SDA pin in a pinch, as the i2c bus shouldn't care as long as the clock isn't changing.
Jonathan
I would really like to see some 6.25MHz and 10MHz results please.
lonesock:
No other pins are used. My code just uses the an extended variation of the PLL Phil Pilgrim used in the video counters.
FindFreq: Test the crystal frequency v0.10
*** Found Clock 104000000Hz, mode $6F, Crystal 6500000Hz, (116,220)
In my tests maxing out the PLL, it seems to run at about 225 MHz, and of course it is fed by the NCO * 16, so the NCO needs to be running at or above 14 MHz. So if the actual system clock speed is any slower than 28 MHz I can't use this technique. (Which unfortunately means I can't get a decent read on RCFAST)
Jonathan
I am not quite sure what this means. Does it mean that the counter PLL cannot lock with an internal 80MHz clock??? It certainly appears so.
Take the 5MHz x16 example...
I set 5MHz x8 (40MHz internal clkfreq) and test the counter PLL. If it locks then I reliably get 116 as a result (thats the first of the numbers I output in the message).
If I get 116 +/- (110..119) then I proceed to set x16 and obtain the counter results again.
From this second result, I can determine roughly the xtal frequency (clkfreq) ranges. This is the second number I output)
Thanks for the idea to use video mode! I had been using a pin previously, which was inelegant.
Jonathan
I would really like some more testing please !
I want to publish a boot program/module/object that can automatically detect and set the crystal/frequency used
And add some generic 5meg platforms also.
6.250 MHz xtal:
FindFreq: Test the crystal frequency v0.10
*** Found Clock 104000000Hz, mode $6F, Crystal 6500000Hz, (116,216)
6.000 MHz xtal:
FindFreq: Test the crystal frequency v0.10
*** Found Clock 100000000Hz, mode $6F, Crystal 6250000Hz, (116,206)
5.000 MHz xtal:
FindFreq: Test the crystal frequency v0.10
*** Found Clock 84000000Hz, mode $6F, Crystal 5250000Hz, (116,171)
4.9152 MHz xtal:
FindFreq: Test the crystal frequency v0.10
*** Found Clock 84000000Hz, mode $6F, Crystal 5250000Hz, (116,171)
4.000 MHz xtal:
(didn't like it. I'm not surprised!)
My code ignores anything below 5MHz so I expect that 4MHz would fail. Interesting all those frequencies were found to be .25MHz higher.
With more results hopefully I can tweek the ranges to reliably differentiate between common use values.
FindFreq: Test the crystal frequency v0.10
*** Found Clock 80000000Hz, mode $6F, Crystal 5000000Hz, (116,163)
PPDBoard:
FindFreq: Test the crystal frequency v0.10
*** Found Clock 84000000Hz, mode $6F, Crystaì 5250000Hz, (116,170)
Those numbers at the end tell me the counts so I can determine the range/spread in various props..
Hydra Board 10.0 MHZ XTAL
FindFreq: Test the crystal frequency v0.50
*** Found Clock 76000000Hz, mode $6E, Crystal 9500000Hz, (162,0)
Hydra Board 6.25 MHZ XTAL
FindFreq: Test the crystal frequency v0.50
*** Found Clock 100000000Hz, mode $6F, Crystal 6250000Hz, (116,204)
Hydra Board 5.00 MHZ XTAL
FindFreq: Test the crystal frequency v0.50
*** Found Clock 80000000Hz, mode $6F, Crystal 5000000Hz, (116,162)
QuickStart Rev A 5.00 MHZ XTAL
FindFreq: Test the crystal frequency v0.10
*** Found Clock 80000000Hz, mode $6F, Crystal 5000000Hz, (116,167)
EDIT: I changed the SPIN file to reflect the Revision Number in the Serial Output.
I also had to comment out
so the output would stay on the screen.