Rising-Edge to Rising-Edge Triggered Mode with FCC_IN Trigger
The following steps describe how to use the FCC to count the number of source clock pulses within the trigger period set by the reference clock, with the FCC_IN pin being selected as the reference clock and the SYSOSC being selected as the source clock. This example would be useful for calibrating the SYSOSC frequency with respect to an accurate clock source provided to the FCC_IN pin externally.
- Set the source clock to SYSOSC by configuring the FCCSELCLK field in the GENCLKCFG register.
- Set the reference clock to FCC_IN by clearing the FCCTRIGSRC bit in the GENCLKCFG register.
- Select rising-edge to rising-edge triggering by clearing the FCCLVLTRIG bit in the GENCLKCFG register.
- Select the desired number of reference clock periods to count the source clock over in the FCCTRIGCNT field in the GENCLKCFG register.
- Ensure that SYSOSC is enabled at the desired frequency, and that the external clock source connected to FCC_IN is running correctly before continuing.
- Write the GO bit and KEY field to the FCCCMD register to start the FCC capture on the next trigger clock period.
- Poll the FCCDONE status bit in the CLKSTATUS register. When the capture completes, FCCDONE will be set by hardware. FCCDONE is read-only and is automatically cleared by hardware when a new capture is started.
- Extract the resulting count from the 22-bit DATA field in the FCC register.
Rising-Edge to Rising-Edge Triggered Mode with LFXT Trigger
The following steps describe how to use the FCC to count the number of source clock pulses within the reference clock period, with the LFXT being selected as the reference clock and the SYSOSC being selected as the source clock. This example would be useful for calibrating the SYSOSC frequency with respect to an accurate 32.768kHz watch crystal.
- Set the source clock to SYSOSC by configuring the FCCSELCLK field in the GENCLKCFG register.
- Set the reference clock to LFXT by setting the FCCTRIGSRC bit in the GENCLKCFG register.
- Select rising-edge to rising-edge triggering by clearing the FCCLVLTRIG bit in the GENCLKCFG register.
- Select the desired number of reference clock periods to count the source clock over in the FCCTRIGCNT field in the GENCLKCFG register.
- Ensure that SYSOSC is enabled at the desired frequency, and that the LFXT is running correctly before continuing.
- Write the GO bit and KEY field to the FCCCMD register to start the FCC capture on the next trigger clock period.
- Poll the FCCDONE status bit in the CLKSTATUS register. When the capture completes, FCCDONE will be set by hardware. FCCDONE is read-only and is automatically cleared by hardware when a new capture is started.
- Extract the resulting count from the 22-bit DATA field in the FCC register. If SYSOSC was running at 32MHz and FCCTRIGCNT was set to '0' (one reference clock period), the result should be approximately 976 cycles counted within the single 32.768kHz period.
- To calibrate SYSOSC for 24MHz operation, the SYSOSC user trim must be adjusted until approximately 732 cycles are counted.
- To calibrate SYSOSC for 16MHz operation, the SYSOSC user trim must be adjusted until approximately 488 cycles are counted.
In general, increasing the FCCTRIGCNT value increases the accuracy of the measurement, at the expense of longer measurement time.
Level Triggered Mode with FCC_IN Trigger and HFCLK_IN Clock
The following steps describe how to use the FCC to count the number of source clock pulses within one external reference pulse window, with HFCLK_IN being selected as the source clock. This example would be useful for measuring the frequency of an external clock source with respect to a fixed pulse width driven by an external signal.
- Set the source clock to HFCLK by configuring the FCCSELCLK field in the GENCLKCFG register.
- Set the trigger clock to the FCC_IN pin function by clearing the FCCTRIGSRC bit in the GENCLKCFG register.
- Set level triggering by setting the FCCLVLTRIG bit in the GENCLKCFG register.
- Ensure that IOMUX is configured for FCC_IN, that HFCLK is configured for HFCLK_IN, and that an external clock is sourcing HFCLK_IN.
- Write the GO bit and KEY field to the FCCCMD register to start the FCC capture when FCC_IN goes logic high. Note that if FCC_IN is already logic high when GO is asserted, counting starts immediately. When using level mode, FCC_IN should be low when GO is set, and the trigger pulse should be sent to FCC_IN after GO is set.
- Poll the FCCDONE status bit in the CLKSTATUS register. When the capture completes, FCCDONE will be set by hardware. FCCDONE is read-only and is automatically cleared by hardware when a new capture is started.
- Extract the resulting count from the 22-bit DATA field in the FCC register.