MX Foundation 4
Aperiodic Transmission

In aperiodic mode, the user application is in complete control of the transmission.

The mxfFlexDIOTxAperiodicWrite() function is used to send a FIFO buffer containing one or many MXF_FLEXDIO_DATAREC records that define the transition to perform on the discrete output lines.

After the application is initialized and the channel is set, the application must allocate a buffer for MXF_FLEXDIO_DATAREC record objects. The state of the discrete output lines is stored using the data field.

The transmit timing is controlled by the timeTag record field in conjunctions with the startTime parameter of the mxfFlexDIOTxAperiodicWrite() function.

The aperiodic modes of transmission can be defined as follows:

  • Default Transmission

    In this mode, a relative start time can be specified to send the records. The records are then sent back-to-back. The record's time tag can't be used.

  • Transmission with Absolute Timing

    In this mode, an absolute start time is specified to send the records. The records are then sent back-to-back. The record's time tag can't be used.

  • Transmission with Record Timing

    In this mode, each record's time tag is set in the future (in sequence) for the transmission of the records. The start time can't be used with this option.

  • Transmission with Record Relative Timing

    With this method, the records' time tag specify the relative time between each records for transmission. The start time can't be used with this option.


Pulse Schedule Mode

The transmission can changed the line state to high or low by setting the bit to 1 or 0 in the data field, but a pulse pattern can also be set by using the control, highDuration and lowDuration fields. The pulse schedule mode can, for example, be used to generate a clock by transmitting only one record by the application. The pulse will start by a high duration or a low duration based on the value set in data field. If the bit is set to 1, the pulse will start with the high duration. If the bit is set to 0, the pulse will start with the low duration.

Note
The pulse schedule mode is available only on the first eight discrete pins.


Example

The example below shows how to change the state of discrete output based on the state of discrete input.

flexdio.c

The example below shows how to change the state of discrete output with record timing.

flexdio_event_handler.c

#define MAX_TX_RECORDS_TO_TRANSMIT 4
HMXF_SERVER server;
HMXF_CHANNEL txChannel;
HMXF_BUFFER txBuffer;
size_t txBufferSize=0;
MXF_FLEXDIO_DATAREC* txHostBuffer=0;
uint32 rc;
uint64 data;
// Allocate buffer for tx data
if (!rc)
{
txBufferSize = MAX_TX_RECORDS_TO_TRANSMIT*sizeof(MXF_FLEXDIO_DATAREC);
rc = mxfTxAperiodicBufferAlloc(txChannel, MXF_TXAPERIODIC_PRIORITY_HIGH, txBufferSize, &txBuffer, NULL);
// Host buffer allocation
if(!rc)
{
txHostBuffer = (MXF_FLEXDIO_DATAREC*) calloc(1, txBufferSize);
if(!txHostBuffer)
rc = MAXT_ERROR_MEM;
}
}
// Sets timebase to RTC nsec
if(!rc)
rc = mxfSystemTimeBaseSet(server, MXF_TIMEBASE_DEVICE_NSEC);
if(!rc)
{
// Prepares records
rec = txHostBuffer;
for(data=0; data<MAX_TX_RECORDS_TO_TRANSMIT && !rc; data++)
{
rec->timeTag = 100*1000*1000+(data*10000); // 10 msec between each record
rec->control = 0;
rec->repeatCount = 1;
rec->data = data;
rec->edge = 0x0000000000000003ULL;
rec->highDuration = 0;
rec->lowDuration = 0;
}
if(!rc)
rc = mxfFlexDIOTxAperiodicWrite(txBuffer, MXF_TXAPERIODIC_FLAG_USE_RECORD_RELATIVE_TIME, 0, 1, txHostBuffer);
}
...
Updated 10/23/2023