The Counter/Delay (CNT/DLY) macrocell is a multi-function component. A CNT/DLY component may include the following functions: counter, delay, finite state machine (FSM), edge detector, wake-sleep controller (WS Ctrl), frequency detector and one-shot. As a counter, the macrocell counts to the given register value and creates a pulse when it has reached the value or is reset. As a delay, it postpones rising and/or falling edges for the duration of the register value. As a finite state machine, the counter’s data can be manipulated up or down. As an edge detector, the macrocell generates a pulse on a rising and/or falling edge. As a Wake-Sleep controller, the macrocell controls the power up/down of analog blocks ADC and ACMP. As a frequency detector, the macro-cell is a watchdog timer and signifies if the input frequency is too slow. As a One-Shot macrocell, an input edge triggers a one-shot of counter-data length.
• Delay: postpones the rising and/or falling edge of the input signal;
• Counter/FSM: generates a positive pulse when value is reached, or when reset;
• Edge detect: generates a pulse on a rising and/or falling edge;
• WS Ctrl: generates on and off signals to ADC and ACMP
• One-Shot: generates a long high pulse.
• Freq Detect: signifies if the input frequency is too slow.
The length of Counter/Delay period. CNT/DLY bit widths are 16-bit or 8-bit, from 1 to 65535 or 1 to 255 respectively. It is recommended to use larger counter data values for less error.
Calculates time period with the following formulas:
• Output Period: [(Counter data + 1) / CLK input frequency – Offset];
• Delay time: [(Counter data + 2) / CLK input frequency – Offset];
CLK Input Frequency is the frequency of the selected Clock Source and Offset is the asynchronous time offset between the input signal and the first clock pulse.
If an input pulse is < delay time, the pulse would be filtered out. This feature can be useful for de-glitching.
In Delay or edge detect mode, select which edge to delay. In Counter Mode with Reset In, select which edge resets the counter to 0.
• Both: both rising and falling edges of pulse are delayed;
• Falling: only falling edge delayed;
• Rising: only rising edge delayed;
• High Level Reset: When RESET IN is high, counter is reset to 0;
Invert the polarity of the macro-cell output.
The Q mode selects the reset function for a counter/FSM when the data wraps around at 0 or max value. Set would load the counter/FSM data from a source, and Reset would load a zero.
• Set: loads either the design counter data, ADC data, or SPI data. Source data is selectable through the parameter ‘FSM data’ under ‘Connections’;
• Reset: loads 0;
In FSM mode, the user may control the counter value using macro-cell inputs “UP, DOWN, KEEP” .
UP: macro-cell input ‘UP’ is a count direction controller. A digital high sets the FSM to count up in value. A digital low sets the FSM to count down in value and both will wrap around at 0 or maximum.
KEEP: macro-cell input ‘KEEP’ is a latching mechanism. A digital high latches the current value in FSM until ‘KEEP’ is released low. A digital low resumes normal operation where a clock input will increment or decrement its counter value.
• Counter data source: The FSM data will start at this number. When reaching 0 or max16-bit the FSM will not reload this value but instead wraps around;
In FSM mode, the RESET_IN input can stop and restart the FSM.
For more detailed information, see datasheet section CNT/DLY Timing Diagram
Use WS Ctrl for controlling the power on and power off of analog blocks ACMP and ADC. WS Ctrl frequency is sourced by the OSC. The sleep will turn off the regulator and bandgap.
Enable/Disable this wake sleep control to ALL ACMPs. ACMP PWR UP has highest priority.
Enable/Disable this wake sleep control to ADC. ADC PWR DN has highest priority.
When the OSC is powered down, chose whether the Analog Blocks stay in sleep mode or wake mode.
• Force sleep (LOW): when OSC is powered down;
• Force wake (HIGH): when OSC is powered down;
Reset In resets the Counter to 0 when the RESET IN input has a valid edge. The edge is determined by the Edge select parameter. Valid in Counter Mode only.
The initial output after reset is High for the duration of one clock cycle.
All Counter/Delays have OSC0/1/4/12/24/64, OSC1, and Ext Clock connections.
Both counter and delay configurations can be sourced by an internal or external oscillator. Internal clock (OSC0, OSC1) without divider connections are not shown. (See OSC Info block for more information on the different CLK sources.)
If the Counter Reset is asserted at the same time as a rising clock edge, it is possible that the Counter Data will be reset incorrectly and the counter output may appear faster than expected. This phenomenon appears more often as the clock frequency increases. Refer to SLG46531 Errata Sheet for more information.