MX Foundation 4
Periodic Frame Service

The BC channel of MIL-1553 modules supports this service (Logical channel 1 & 35).

Refer to MXF_MIL1553_TXPERIODIC_MJRFRAME_MSG structure for major frame building.

The major frame can contain up to 2500 minor frames and a total of 6500 messages.

The minor frame rate may be configured between 50 microseconds and 26214375 (rev 1.0.1 or later) or 6553575 (rev 1.0.0) microseconds on Enhanced BC and 1638375 microseconds on IPM-1553-MRT, by step of 25 microseconds (duration parameter of mxfMIL1553TxPeriodicMajorFrameStart() function or duration field of MXF_MIL1553_TXPERIODIC_MJRFRAME_MINOR_PROPERTIES structure).

Each minor frame may have a branch option (Conditional branch, Go To, or End of Major Frame).

Each message may contain a branching condition option. (AND, EQUAL or NOT EQUAL condition on any word index of the message). When the condition is successfully verified, the branching may go to any message within the major frame.

Each element of the major frame corresponds to the MXF_MIL1553_TXPERIODIC_MJRFRAME_MSG structure. It contains the command to be sent, the delay between two transmissions, the retry option (how to manage the retry when a transmission error occurs), the error option (what to do if an error is detected), and other options.

It is possible to set up a schedule of command transmissions by thoroughly building up the major frame using the appropriate commands.

Before setting the major frame, it is suggested to clear it using the mxfTxPeriodicMajorFrameClear() function.

The minor frame can then be set using the mxfMIL1553TxPeriodicMajorFrameSet() function. By default, the major frame is empty.

For advanced minor frame branch options, the MXF_MIL1553_TXPERIODIC_MJRFRAME_MINOR_PROPERTIES structure may be used. By default, all minor frames are sent consecutively, and the major frame loops forever.

To set the data associated to the command, refer to the Periodic Update Message Service section.

Building a major frame:

#define M_ADDRESS 5
#define M_SUBADDRESS 3
HMXF_SERVER server;
HMXF_CHANNEL bc;
HMXF_BUFFER tx=0;
HMXF_BUFFER tx2=0;
size_t txBufferSize=0;
MXF_MIL1553_DATAREC* txBuffer=NULL;
...
// Sets timebase to RTC nsec
if(!rc)
rc = mxfSystemTimeBaseSet(server, MXF_TIMEBASE_DEVICE_NSEC);
// Allocates 1KB buffer for tx data
if(!rc)
{
txBufferSize = 1024;
// Flex1553 allocation
rc = mxfTxPeriodicUpdateMsgBufferAlloc(bc, 0, txBufferSize, &tx, NULL);
if(!rc)
rc = mxfTxPeriodicUpdateMsgBufferAlloc(bc, 1, 0, &tx2, NULL);
// Host allocation
if(!rc)
{
txBuffer = (MXF_MIL1553_DATAREC*)malloc(txBufferSize);
if(!txBuffer)
rc = MAXT_ERROR_MEM;
}
}
// Clears the major frame
if(!rc)
// Sets the minor frame #0 using 3 Commands
if(!rc)
{
memset(minorFrame, 0, sizeof(minorFrame));
// Command #0 : Address 5, Subaddress 3, RX, 16 words
rc = mxfMIL1553CommandCompose(M_ADDRESS, M_SUBADDRESS, MXF_MIL1553_COMMAND_DIR_RX, 16, &minorFrame[0].command);
minorFrame[0].modulo = 1;
minorFrame[0].buffer = tx;
// Command #1 : Address 5, Subaddress 3, TX, 16 words
if(!rc)
{
rc = mxfMIL1553CommandCompose(M_ADDRESS, M_SUBADDRESS, MXF_MIL1553_COMMAND_DIR_TX, 16, &minorFrame[1].command);
minorFrame[1].modulo = 1;
minorFrame[1].buffer = tx2;
}
// Command #2 : Address 5, Mode Command 16, TX
if(!rc)
{
rc = mxfMIL1553CommandCompose(M_ADDRESS, 0, MXF_MIL1553_COMMAND_DIR_TX, 16, &minorFrame[2].command);
minorFrame[2].modulo = 1;
minorFrame[2].buffer = tx2;
}
if(!rc)
rc = mxfMIL1553TxPeriodicMajorFrameSet(bc, 0, 0, 3, minorFrame, NULL);
}
// Sets default data for address 5, subaddress 3
if(!rc)
{
txRec1553 = (MXF_MIL1553_DATAREC *)txBuffer;
memset(txRec1553, 0, sizeof(MXF_MIL1553_DATAREC));
txRec1553->repeatCount = 1;
txRec1553->dataSize = 34; //34 bytes (command + 16 words)
txRec1553->data[0] = 0x0000; //Not used
txRec1553->data[1] = 0x0000;
txRec1553->data[2] = 0x1111;
txRec1553->data[3] = 0x2222;
txRec1553->data[4] = 0x3333;
txRec1553->data[5] = 0x4444;
txRec1553->data[6] = 0x5555;
txRec1553->data[7] = 0x6666;
txRec1553->data[8] = 0x7777;
txRec1553->data[9] = 0x8888;
txRec1553->data[10] = 0x9999;
txRec1553->data[11] = 0xAAAA;
txRec1553->data[12] = 0xBBBB;
txRec1553->data[13] = 0xCCCC;
txRec1553->data[14] = 0xDDDD;
txRec1553->data[15] = 0xEEEE;
txRec1553->data[16] = 0xFFFF;
rc = mxfMIL1553TxPeriodicUpdateMsgWrite(tx, 1, txBuffer);
}
// Starts the major frame with 250 msec rate
if(!rc)
rc = mxfMIL1553TxPeriodicMajorFrameStart(bc, 0, 250000000, NULL);
...
// Stops the major frame
if(!rc)
if(!rc)
...

mil1553_bc.c

Note
If two commands with the same buffer are close to each other in the minor frame, it can happen that the firmware doesn't have the time to update the buffer before the next command is sent, so the same data will be sent twice. If they need to have different data, simply assign a different buffer to one of the command and update both buffers individually.



Branch Options

By default, the major frame is set to loop, forever, each minor frame consecutively. However, the major frame branch function may be configured with the “Go To” and “End of Frame” options.

Each minor frame may be configured with the mxfMIL1553TxPeriodicMajorFrameSet() function (refer to the MXF_MIL1553_TXPERIODIC_MJRFRAME_MINOR_PROPERTIES structure).

HMXF_CHANNEL bc;
uint32 rc;
...
// Sets Go To minor frame 0
memset(&mfProp, 0, sizeof(mfProp));
mfProp.modulo = 1;
mfProp.repeatCount = 1;
mfProp.options = MXF_MIL1553_TXPERIODIC_MJRFRAME_MINOR_PROPERTIES_OPT_BRANCH_GOTO;
mfProp.branchIndex = 0;
rc = mxfMIL1553TxPeriodicMajorFrameSet(bc, 0, 0, 2, minorFrame, &mfProp);
...

mil1553_cond_branch_1.c
mil1553_cond_branch_2.c

Conditional Branch Options

Each BC message contained in the minor frames may be configured to verify a condition before switching to the next message. When this condition is true, a branch occurs to the specified destination (minor frame/message pairs). Refer to the MXF_MIL1553_TXPERIODIC_MJRFRAME_MSG structure.

#define BUF_SA3_TX 1
HMXF_CHANNEL bc;
MXF_MSGID_MIL1553 bcMsgID[4]={{MXF_MIL1553_MSGTYPE_RX,RT_ADRS,3,0},{MXF_MIL1553_MSGTYPE_TX,RT_ADRS,3,0},{MXF_MIL1553_MSGTYPE_RX,RT_ADRS,5,0},{MXF_MIL1553_MSGTYPE_TX,RT_ADRS,5,0}};
uint32 rc;
...
// Command #1 : Address 5, Subaddress 3, TX, 2 words, delay of 1 msec from preceding command or start of minor frame, conditional branch to minor frame 1 if status is not equal to 0x2800
if(!rc)
{
rc = mxfMIL1553CommandCompose(bcMsgID[BUF_SA3_TX].address, bcMsgID[BUF_SA3_TX].subAddress, bcMsgID[BUF_SA3_TX].type, 2, &minorFrame[1].command);
if(!rc)
{
minorFrame[1].options = MXF_MIL1553_TXPERIODIC_MJRFRAME_MSG_OPT_DELAY;
minorFrame[1].modulo = 1;
minorFrame[1].buffer = bcBufferTx[BUF_SA3_TX];
minorFrame[1].delay = 8000; // 1 msec in 1/8 of bit time
minorFrame[1].branchMinorIndex = 1;
minorFrame[1].branchMsgIndex = 0xFFFF;
minorFrame[1].condMask = 0xFFFF;
minorFrame[1].condData = (uint16)(bcMsgID[BUF_SA3_TX].address<<11);
rc = mxfMIL1553ConditionalBranchCompose(MXF_MIL1553_TXPERIODIC_MJRFRAME_MSG_CONDBRANCH_OPT_NOTEQUAL, 0, &minorFrame[1].condBranch);
}
if(!rc)
rc = mxfMIL1553TxPeriodicMajorFrameSet(bc, 0, 0, 2, minorFrame, &mfProp);
}
...

mil1553_cond_branch_1.c
mil1553_cond_branch_2.c

Updated 10/23/2023