<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Generating Square wave based external low power crystal? in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Generating-Square-wave-based-external-low-power-crystal/m-p/123910#M58</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have a 32.768kHz external xtal. I want to generate square wave based this crystal to measure its frequency. I can't measure it directly from EXAL pin due to probe capacitance. I have a high precision frequency counter. Do you know a way to generate a signal based directly this crystal without using internal DCO? I don't want jitter at output.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;MCU is MC9S08LC60&lt;/DIV&gt;&lt;DIV&gt;CW v5.1 C Compiler&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I tried common outputs of LCD module of the MCU. but no change. I&amp;nbsp;didn't understand why it is not &lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-sad.gif"&gt;&lt;IMG alt=":smileysad:" class="emoticon emoticon-smileysad" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-sad.gif" title="Smiley Sad" /&gt;&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Feb 2007 03:55:01 GMT</pubDate>
    <dc:creator>BasePointer</dc:creator>
    <dc:date>2007-02-21T03:55:01Z</dc:date>
    <item>
      <title>Generating Square wave based external low power crystal?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Generating-Square-wave-based-external-low-power-crystal/m-p/123910#M58</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have a 32.768kHz external xtal. I want to generate square wave based this crystal to measure its frequency. I can't measure it directly from EXAL pin due to probe capacitance. I have a high precision frequency counter. Do you know a way to generate a signal based directly this crystal without using internal DCO? I don't want jitter at output.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;MCU is MC9S08LC60&lt;/DIV&gt;&lt;DIV&gt;CW v5.1 C Compiler&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I tried common outputs of LCD module of the MCU. but no change. I&amp;nbsp;didn't understand why it is not &lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-sad.gif"&gt;&lt;IMG alt=":smileysad:" class="emoticon emoticon-smileysad" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-sad.gif" title="Smiley Sad" /&gt;&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Feb 2007 03:55:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Generating-Square-wave-based-external-low-power-crystal/m-p/123910#M58</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2007-02-21T03:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Square wave based external low power crystal?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Generating-Square-wave-based-external-low-power-crystal/m-p/123911#M59</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Is your frequency&amp;nbsp;counter capable of measuring low frequencies&amp;nbsp; to high resolution (e.g. 0.001 Hz), or alternatively, is it capable of period measurement (say 0.1 us resolution, or better)?&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;In either case, you might setup a PWM output of known frequency, and with 50 percent duty cycle.&amp;nbsp; For frequency measurement, the PWM frequency should be as high as feasible.&amp;nbsp; For period measurement, you should keep the PWM frequency low for best resolution, e.g. perhaps a 1 Hz frequency, if within the capabilities of the counter.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Another method suitable for frequency measurement, is to toggle an output pin within a very tight program loop,&amp;nbsp;with a&amp;nbsp;known number of cycles per loop.&amp;nbsp; This should be written in assembly code.&amp;nbsp; The COP timer and all interrupts should remain disabled during the test.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;LOOP:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;BRSET&amp;nbsp; 0,PTA&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;NOP&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Padding for 50% duty cycle&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;NOP&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;NOP&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;BRCLR&amp;nbsp; 0,PTA&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;BRA&amp;nbsp;&amp;nbsp;&amp;nbsp; LOOP&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Since the frequency or period measurement should occur over a one second measurement interval, or thereabouts, any jitter should be averaged over this period, and I would generally not expect this to be an issue.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;If you must directly measure the frequency of the 32 kHz crystal, you will need &lt;U&gt;external&lt;/U&gt; buffer components that present a fixed load to the crystal whether or not a counter is connected.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;This might consist of a pair of HCMOS inverter stages (specifically of the unbuffered type).&amp;nbsp; The first stage would operate in a quasi-analog fashion, with a high value resistor between input and output (say 4.7M).&amp;nbsp; The input would be capacitively coupled to one of the oscillator pins (say 10p).&amp;nbsp; The output of the first stage would connect to the input of the second stage, and the counter would connect to the output of the second stage.&amp;nbsp;&lt;/FONT&gt; &lt;FONT size="2"&gt;You would still need to take into account the input capacitance of the buffer&amp;nbsp;during the design of the oscillator.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Feb 2007 11:50:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Generating-Square-wave-based-external-low-power-crystal/m-p/123911#M59</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-02-21T11:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Square wave based external low power crystal?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Generating-Square-wave-based-external-low-power-crystal/m-p/123912#M60</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi bigmac,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The counter I have is capable &lt;FONT size="2"&gt;100nHz resolution for 1Hz.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;A href="http://www.instek.com/GFC-8131H.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.instek.com/GFC-8131H.htm&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I can't use timer modules of the LC60. Because their time base is all DCO based in FEE mode. I can't define clock base directly as external crystal.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;CLKSB:CLKSA TPM Clock Source to Prescaler Input0:0 No clock selected (TPMx disabled)0:1 Bus rate clock (BUSCLK)1:0 Fixed system clock (XCLK)1:1 External source (TPMxCLK)1,2&lt;/PRE&gt;&lt;BR /&gt;In the MCU, there are two module&amp;nbsp;that uses directly external crystal. First is RTI and the second is LCD.&lt;BR /&gt;RTI module has no output, it just generate interrupt. LCD module has output that&amp;nbsp;has frequency&amp;nbsp;External Clock Frequency / [(1+CLKADJ)*8*(2^LCLK)*2]. The final frequency with this way could be 128Hz directly based external crystal. My tests show me it is varying and I don't know why it is.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'm new at Frescale HCS08 family, I don't know much about its assembly language and didn't work it before. I think the code you suggested should work in FBE mode to disable DCO. I can also use directly timer module in this mode. But my entire application can't run at this frequency. So this is not suitable way for me.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you,&lt;/DIV&gt;&lt;DIV&gt;BP&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Feb 2007 16:29:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Generating-Square-wave-based-external-low-power-crystal/m-p/123912#M60</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2007-02-21T16:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Square wave based external low power crystal?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Generating-Square-wave-based-external-low-power-crystal/m-p/123913#M61</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi BP,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Why can't you just write a programme that just has an empty main loop and an RTI ISR that simply toggles an output? This would then provide a signal that is in direct proportion to the crystal frequency.&lt;/DIV&gt;&lt;DIV&gt;Shouldn't matter how you write the code, the delay (from RTI to output toggle) should be the same everytime.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Feb 2007 19:26:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Generating-Square-wave-based-external-low-power-crystal/m-p/123913#M61</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2007-02-21T19:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Square wave based external low power crystal?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Generating-Square-wave-based-external-low-power-crystal/m-p/123914#M62</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I write the code below. It directly toggles PTC2/TPM1CH0 pin with compare output at about 4096Hz.&lt;/DIV&gt;&lt;DIV&gt;The counter tell me 4096.0208(+5.1ppm) - 4096.0217(+5.3ppm) as its frequency. There are still a small jitter?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If I measure it directly EXTAL pin with a probe 10:1, 10pF, it says 32767.745Hz (-7.78ppm)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;  DisableInterrupts;    SOPT1 = 0b01110011;  SOPT2 = 0b10000000;    ICGC2 = 0;  ICGC1 = 0b00110001;  // FBE mode, fbus=16.768KHz    TPM1MOD = 1;  TPM1C0V = 0;  TPM1C0SC = 0b00010100; // toggle at Fext / 8 -&amp;gt; 32768/8=4096Hz  TPM1SC = 0b00001000;    while(1);&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This is a kind of&amp;nbsp;RTC application and I need to calibrate&amp;nbsp;every products to max 2ppm. The real application code use FEE mode. Do you have a calibration method for mass production? I don't like this two program method.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you,&lt;/DIV&gt;&lt;DIV&gt;BP.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Feb 2007 02:07:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Generating-Square-wave-based-external-low-power-crystal/m-p/123914#M62</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2007-02-22T02:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Square wave based external low power crystal?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Generating-Square-wave-based-external-low-power-crystal/m-p/123915#M63</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello BP,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I think there are a few points that need to be considered.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;You are using a crystal type originally intended for use in wrist watches, that when worn, are in a fairly "constant temperature" environment.&amp;nbsp; The frequency drift with temperature change can be significantly higher for this type of low frequency crystal, than for a higher frequency.&amp;nbsp; I presume your product may be subject to considerably wider temperature variation, and you could be talking multiples of 10 ppm.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;The crystal frequency will drift with time, due to aging.&amp;nbsp; Look at the data for the crystal you are using, but I suspect it is unlikely to be less than 1 ppm for the first 12 months.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Jitter of the oscillator output will have little effect on a "normal" RTC application, where resolution is&amp;nbsp;one second.&amp;nbsp; The average frequency is what needs to be measured.&amp;nbsp; When you measure the frequency, you should be aware of the averaging period for the measurement setup, and choose a period in the region of one second, for&amp;nbsp;any fine adjustment - for coarse adjustment the measurement period could be less.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;For a factory adjustment procedure, there is probably little point in attempting to adjust finer than about 0.5-1.0 ppm.&amp;nbsp;&amp;nbsp;With&amp;nbsp;your suggested figure of 2 ppm, and&amp;nbsp;a measured jitter of&amp;nbsp; approximately 0.2 ppm, you should be able to easily adjust to this accuracy.&amp;nbsp; Just ignore any variation of the least significant digit of the counter reading.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;The change of frequency (13 ppm) is the sort of figure to be expected with the capacitive loading by the oscilloscope probe.&amp;nbsp; If you want to measure crystal frequency directly, you would require the hardware buffer approach, as previously described.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;If you don't want to add the hardware, you will need the special firmware specifically for the measurement.&amp;nbsp; One possibility is to&amp;nbsp;commence output of the calibration&amp;nbsp;signal (the code you have posted would be suitable), whenever a special frequency calibrate mode is initiated.&amp;nbsp; This would then continue until the next reset, when normal operation would resume.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Feb 2007 09:25:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Generating-Square-wave-based-external-low-power-crystal/m-p/123915#M63</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-02-22T09:25:35Z</dc:date>
    </item>
  </channel>
</rss>

