Skip to main content
Skip table of contents

13.2.4 Pulse Out [T-Series Datasheet]

Overview

T4 Capable DIO: DIO6, DIO7 (aka FIO6, FIO7)

T7 Capable DIO: DIO0, DIO2, DIO3, DIO4, DIO5 (aka FIO0, FIO2, FIO3, FIO4, FIO5)

T8 Capable DIO: DIO2, DIO3, DIO4, DIO5, DIO6, DIO7, DIO8, DIO11, DIO12 (aka FIO2, FIO3, FIO4, FIO5, FIO6, FIO7, EIO0, EIO3, EIO4)

Requires Clock Source: Yes

Index: 2

Streamable: No

Pulse output will generate a specified number of pulses and then stop.  For continuous pulse output use the PWM Out feature.

Operation

The high time and the low time are specified relative to the clock source the same way as PWM with Phase.

Clock#Frequency = CoreFrequency / DIO_EF_CLOCK#_DIVISOR
PulseOutFrequency = Clock#Frequency / DIO_EF_CLOCK#_ROLL_VALUE

if CONFIG_A > CONFIG_B:
DutyCycle% = 100 * (DIO#_EF_CONFIG_A - DIO#_EF_CONFIG_B) / DIO_EF_CLOCK#_ROLL_VALUE

For the common case that CONFIG_B is fixed at 0:
DutyCycle% = 100 * DIO#_EF_CONFIG_A / DIO_EF_CLOCK#_ROLL_VALUE

For a 50% duty cycle:

DIO#_EF_CONFIG_A = DIO_EF_CLOCK#_ROLL_VALUE / 2

See the DIO-EF Clock Source section for more information about your device core frequency and DIO_EF clock source settings.

DIO_EF_CLOCK#_ROLL_VALUE is a 32-bit value for CLOCK0 and a 16-bit value for CLOCK1 & CLOCK2. A value of 0 corresponds to the max roll value of 232 for the 32-bit clock or 216 for 16-bit clocks.

The clock roll value can take up to one pulse out period to update and this does not block subsequent commands from being processed. It is possible to finish updating DIO_EF_CONFIG_A or DIO_EF_CONFIG_B to a value greater than the non-updated clock roll value (which is invalid) but less than the updated clock roll value (which is valid) and throw the error 2565: EF_VALUE_GREATER_THAN_PERIOD.

Potential fixes:

  • disable and re-enable the clock line before updating the clock roll value and  line transition values.
  • Delay for greater than one "non-updated" period between updating the clock roll value and updating the line transition values.

The pulse out mode is very CPU intensive when running at higher frequencies (for example, above 400 kHz). At higher rates the number of pulses should be low to limit execution time, or one of the PWM output modes should be used instead.

Configure

DIO#:  First set the DIO line low (DIO#=0). The line must start low for proper pulse generation.
DIO#_EF_ENABLE: 0 = Disable, 1 = Enable
DIO#_EF_INDEX: 2
DIO#_EF_CLOCK_SOURCE (formerly DIO#_EF_OPTIONS): Specify which clock source to use. 0 for Clock0, 1 for Clock1, or 2 for Clock2.
DIO#_EF_CONFIG_A: When the specified clock source's count matches this value the line will transition from high to low.
DIO#_EF_CONFIG_B: When the specified clock source's count matches this value the line will transition from low to high.
DIO#_EF_CONFIG_C: The number of pulses to generate.
DIO#_EF_CONFIG_D: Not used.

Update

DIO#_EF_CONFIG_A: Sets a new high to low transition point. Will take effect when writing CONFIG_C.
DIO#_EF_CONFIG_B: Sets a new low to high transition point. Will take effect when writing CONFIG_C.
DIO#_EF_CONFIG_C: Writing to this value will start a new pulse sequence. If a sequence is already in progress it will be aborted. Numbers previously written to CONFIG_A or CONFIG_B will take effect when CONFIG_C is written.

Read

Results are read from the following registers.

DIO#_EF_READ_A: The number of pulses that have been completed.
DIO#_EF_READ_B: The target number of pulses.

Reset

DIO#_EF_READ_A_AND_RESET: Reads number of pulses that have been completed, then restarts the pulse sequence.

Example

Set up a 1 kHz output with 20% duty cycle.

T4/T7 Pseudocode

First, configure the DIO_EF clock source:

DIO_EF_CLOCK0_ENABLE = 0
DIO_EF_CLOCK0_DIVISOR = 8
DIO_EF_CLOCK0_ROLL_VALUE = 10000
DIO_EF_CLOCK0_ENABLE = 1

Clock0Frequency = 80 MHz / 8 = 10 MHz

PWMFrequency = 10 MHz / 10000 = 1 kHz

Once the clock source is configured, you can configure the pulse output.

Disable the feature:

DIO0_EF_ENABLE = 0

Set DIO0 to output low (use DIO4 on the T4):

DIO0 = 0

User the pulse out index:

DIO0_EF_INDEX = 2

Configure high to low counts:

DIO0_EF_CONFIG_A = 2000

duty cycle = 100 * (2000 - 0) / 10000 = 20%

Configure low to high counts:

DIO0_EF_CONFIG_B = 0

Configure the number of pulses:

DIO0_EF_CONFIG_C = 5000

pulseRuntime = 5000 pulses / 1000 pulses/second = 5 seconds

Enable the feature:

DIO0_EF_ENABLE = 1

T8 Pseudocode

First, configure the DIO_EF clock source:

DIO_EF_CLOCK0_ENABLE = 0
DIO_EF_CLOCK0_DIVISOR = 16
DIO_EF_CLOCK0_ROLL_VALUE = 6250
DIO_EF_CLOCK0_ENABLE = 1

Clock0Frequency = 100 MHz / 16 = 6.25 MHz

PWMFrequency = 6.25 MHz / 6250 = 1 kHz

Once the clock source is configured, you can configure the pulse output.

Disable the feature:

DIO0_EF_ENABLE = 0

Set DIO0 to output low:

DIO0 = 0

User the pulse out index:

DIO0_EF_INDEX = 2

Configure high to low counts:

DIO0_EF_CONFIG_A = 1250

duty cycle = 100 * (1250 - 0) / 6250 = 20%

Configure low to high counts:

DIO0_EF_CONFIG_B = 0

Configure the number of pulses:

DIO0_EF_CONFIG_C = 5000

pulseRuntime = 5000 pulses / 1000 pulses/second = 5 seconds

Enable the feature:

DIO0_EF_ENABLE = 1

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.