microcontrollers: how to detect absolute clock frequency

Hi, To do that, you need another frequency reference than your quartz... Yvan

********************** YBDesign
formatting link
**********************

Enrico Migliore a écrit dans le message : snipped-for-privacy@fatti.com...

Reply to
Yvan BOURNE
Loading thread data ...

Strange concept? can you explain why or what the system is to help give us a few pointers at possible solutions? generally, without another timing source the answer is NO, but there may be other timing sources you could use that may not be obvious.

Al

Enrico Migliore wrote:

--
Please remove capitalised letters to reply
My apologies for the inconvenience
 Click to see the full signature
Reply to
onestone

hi,

I need to detect the absolute frequency of the quartz that feeds my micro. In words, the code must guess the clock frequency without knowing it.

Is it possible?

thanks Enrico Migliore

--
***********************************************************
* Enrico Migliore - Co-founder and Senior Software Engineer
 Click to see the full signature
Reply to
Enrico Migliore

In a nutshell: no.

The only "measurement" of clock frequency a micro can make without _another_ clock source to compare against, would be the 1-bit result of the "go/no-go" test: if code in the micro is currently running, and has been so for a couple of iterations of a big loop, that means the clock frequency must be somewhere within the allowed range, or close to it.

I.e. you can verify that the clock is not zero, and it's not way too high for the micro. Beyond that, a random number would be as good as any other as any other result.

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

ti serve per la seriale o cosa??

"Enrico Migliore" ha scritto nel messaggio news: snipped-for-privacy@fatti.com...

Reply to
Rinux

If your part is powered by AC connection, then you can use this as a reference frequency to phase lock against your quartz. Of course, you'll have to make some assumptions here -- 50Hz vs 60Hz, and whether the system might be running off of a UPS etc..

Reply to
Ian McBride

Enrico, you are using the M16C - right ?

Connect the 32Khz XTAL to XCIN and XCOUT (pins 10/11) and you have got a reference. Other than with a reference there is no way to determine the clock speed.

If you have a derivative with a ring oscillator you can try some bad tricks switching clock modes, but then again...

If you only need a ballpark figure you can also measure the current that the microcontroller (and only the controller) is using and correlate it to the power consumption table supplied in the M16C datasheet.

Well, I'd vote for the 32KHz XTAL. Simplest way to go.

regards /jan

Enrico Migliore schrieb in im Newsbeitrag: snipped-for-privacy@fatti.com...

Reply to
Jan Homuth

You could connect a resister and cap to a port pin.

Reply to
Andre Labelle

Why ?

Answer depends on the precision you need to work to. ie sense 11MHz or 22MHz is clearly different from detect of 11.05921MHz vs 11.05920MHz.

-jg

Reply to
Jim Granville

Hi,

the (external) reference which is absolutely needed could be a serial interface that sends characters like 0xAA or 0x55 and you measure these known lenght charaters with a timer that runs off your microcontroller clock. Many 8-bit micros have internal oscillators know with specified frequency. This is an absolute, thought not highly accurate time reference. (E.g. microchip PICxx, Philips LPC9xx, Cygnal) just to name a few.

Cheers, Schwob

Reply to
Schwob

You clearly need a reference more accurate than the quartz crystal. The clock off GPS is supposed to be pretty good, as is the time from 60kHz time signals .. take it over a long period to smooth out decoding delays. Or a photosensor and leave it outside and measure over a period of days. Or get the MTBF from the manufacturer, and run it until it breaks down..

Paul Burke

Reply to
Paul Burke

To what precision and how much time do we have to get the result? There could be a number of ways to do this, but all depend on your precision requirements and how quickly you need the result. Can you enlighten us more on your requirements?

-ZO

Reply to
ZO

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.