> For the complete documentation index, see [llms.txt](https://mujoseph.gitbook.io/mujoseph-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mujoseph.gitbook.io/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/time-resonant-frequency-capture.md).

# TIME: Resonant Frequency Capture

## Role

Real-time resonant period tracking. Resets with [TIMA](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/tima-resonant-cycle-timing-reference.md#tima-update-event-overview), captures ZCD ([EEV6](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/external-event-eev-configuration.md#eev6-zero-crossing-detection-zcd-feedback-signal)), and updates the [TIM2](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/tim2-open-loop-switching-frequency-and-lead-time.md) auto-reload register (`ARR`) via [DMA](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/dma-configuration.md#dma2-channel-1-role) so lead time tracks frequency. [TIMA Compare 2 and 3](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/tima-resonant-cycle-timing-reference.md#tima-compare-2-role) define the valid capture window (via [TIMF TF2](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/timf-feedback-timeout-watchdog.md#timf-output-tf2-role)).

## Overview

<div data-with-frame="true"><figure><img src="https://2297250131-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzNHSl7dsTOS0XjlMXnIe%2Fuploads%2FWWwRz1sRF8aNypGlvA0B%2Femma_mk1_hrtim_time_overview.svg?alt=media&amp;token=1cbead6e-3126-48f2-9512-e80a99f37b77" alt=""><figcaption><p>HRTIM TIME high-level overview </p></figcaption></figure></div>

## TIME Compare 2 and 3 Roles

<div data-with-frame="true"><figure><img src="https://2297250131-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzNHSl7dsTOS0XjlMXnIe%2Fuploads%2FK9Iu9LbSb6odyTGMwDuR%2Fimage.png?alt=media&amp;token=7908e488-2b01-48ae-96e1-66d82ee7225d" alt="" width="563"><figcaption><p>TIME Compare 2 and 3 block diagram sub-section from <a href="#overview">overview</a></p></figcaption></figure></div>

TIME Compare 2 and 3 events are used by [TIMF TF2](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/timf-feedback-timeout-watchdog.md#timf-output-tf2-role) as set and reset sources, respectively. TIMF TF2 is used as a blanking source for the [EEV6](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/external-event-eev-configuration.md#eev6-zero-crossing-detection-zcd-feedback-signal) (ZCD) event within the TIME context. EEV6 is used to trigger Capture 1 (see [below](#time-capture-1-role)), which is responsible for the real-time resonant period tracking.

The Compare 2 and 3 registers are set by the *DRSSTC\_Driver* when the host [starts a resonant burst via a UART command](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/serial-interface.md#start-frequency-max-positive-negative-deviation).

The figure below demonstrates an EEV6 event blanking within the TIME context. The top plot shows the TIME count register. When the count register is equal to either Compare 2 or Compare 3, an event is generated (middle plot, positive pulse), setting or resetting TIMF TF2 output, respectively (bottom plot, dashed blue trace). If the ZCD feedback signal (EEV6, bottom plot, orange trace) falls within the minimum and maximum frequency bounds set by Compare 2 and 3, it is considered valid, and the real-time resonant period is updated.

<div data-with-frame="true"><figure><img src="https://2297250131-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzNHSl7dsTOS0XjlMXnIe%2Fuploads%2FHCdHoESwmTazEoRxyWTj%2FTIME%20EEV6%20Blanking%20via%20TF2.svg?alt=media&amp;token=67de0d9e-ef84-4bee-ad0e-1d6a99b3815d" alt="" width="563"><figcaption><p>TIME EEV6 event blanking using TIMF output TF2<br>(simulation output from <a href="/mujoseph-docs/emma-mk1-drsstc/drsstctoolbox/hrtim-simulink-model.md">DRSSTCToolbox</a>)</p></figcaption></figure></div>

## TIME Capture 1 Role

TIME Capture 1 is triggered by a blanked [EEV6](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/external-event-eev-configuration.md) (ZCD) event. The blanking source is the [TIMF output TF2](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/timf-feedback-timeout-watchdog.md#output-tf2-role) signal (TIME Compare 2 and 3 are used to shape the TF2 waveform).&#x20;

Capture 1 will contain the real-time resonant period of the DRSSTC. TIME is reset by a [TIMA Update event](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/tima-resonant-cycle-timing-reference.md#tima-update-event-overview). A TIMA Update event is triggered by EEV6, a ZCD crossing; therefore, TIME begins counting from 0 at a ZCD crossing and then stores the count at the next ZCD crossing.&#x20;

A TIME Capture 1 event is also used as a trigger source for a [DMA2 CH1](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/dma-configuration.md#dma2-channel-1-role) transfer.

## TIME Output TE2 Role

<div data-with-frame="true"><figure><img src="https://2297250131-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzNHSl7dsTOS0XjlMXnIe%2Fuploads%2FlrqgtDU7o7T8obVcFUGi%2Fimage.png?alt=media&amp;token=b5a9a69c-ffa1-4be9-a38c-bfb159acaa51" alt="" width="563"><figcaption><p>Output TE2 block diagram sub-section from <a href="#overview">overview</a></p></figcaption></figure></div>

As seen in the figure above, TE2 goes high on [EEV7](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/external-event-eev-configuration.md#eev7-interrupter-source-idle) and low on [EEV9](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/external-event-eev-configuration.md#eev9-prf-cycle-start).

TE2 behaves as the inverse of the interrupter signal:

<div data-with-frame="true"><figure><img src="https://2297250131-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzNHSl7dsTOS0XjlMXnIe%2Fuploads%2F8IBQwhJrKRjI3ffHzNOj%2FTE2%20Synthesis.png?alt=media&amp;token=88588f04-9187-4cf2-9a69-93a9dc13abc6" alt=""><figcaption><p>TE2 waveform. Note the relation to COMP4 output, i.e., the interrupter/PRF signal. <br>(<a href="/mujoseph-docs/emma-mk1-drsstc/drsstctoolbox/hrtim-simulink-model.md">source</a>)</p></figcaption></figure></div>

The TIME TE2 output is used as a blanking source for filtering the [EEV2](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/external-event-eev-configuration.md) event within the [TIMF](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/timf-feedback-timeout-watchdog.md) context:

<div data-with-frame="true"><figure><img src="https://2297250131-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzNHSl7dsTOS0XjlMXnIe%2Fuploads%2FzFo7G9QqAT3Nf9UQExu2%2Fimage.png?alt=media&amp;token=814ef754-9fd1-49f3-885b-d3d74a7496fe" alt="" width="563"><figcaption><p>TE2 serves as blanking source for the EEV2 signal in <a href="/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/timf-feedback-timeout-watchdog.md#overview">TIMF</a></p></figcaption></figure></div>

[EEV2](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/high-resolution-timer-hrtim/external-event-eev-configuration.md#eev2-tim2-trgo-output) ([TIM2 TRGO](/mujoseph-docs/emma-mk1-drsstc/drsstc_driver-firmware-overview/tim2-open-loop-switching-frequency-and-lead-time.md#open-loop-switching-frequency-seed-and-lead-time-injection)) or the TIMA update event resets TIMF, which serves as the [ZCD feedback](/mujoseph-docs/emma-mk1-drsstc/hardware-overview/electrical-design/pcb-design/current-sense.md#zero-crossing-detection-zcd) timeout watchdog. EEV2 is blanked (masked) within TIMF when TE2 is low.&#x20;

EEV2 can reset the feedback watchdog timer only when the interrupter signal is in the inactive/off portion of the PRF cycle. Since EEV2 serves as the "feedback" signal during the open-loop portion of the PRF cycle, it is important to not reset/feed the watchdog on this event since it is not the "true" ZCD feedback that the resonant driver is awaiting.
