Integrator Resources

The official home for NAI Support

Not sure where to start? Try Quick Start Guide or ask a question below!

Toggle Components with Visual Button
JavaScript Form Processing

AR Transmit

AR Transmit Sample Application (SSK 1.x)

Overview

The AR Transmit sample application demonstrates how to transmit ARINC 429 data words using the NAI Software Support Kit (SSK 1.x). ARINC 429 is an avionics data bus standard (ARINC Specification 429) that defines a unidirectional, point-to-point serial bus for communication between aircraft systems. Each ARINC 429 word is 32 bits and carries a structured payload:

Bits Field Description

1-8

Label

Identifies the data type (octal-encoded, transmitted LSB first)

9-10

SDI

Source/Destination Identifier — selects which receiver(s) should process the word

11-29

Data

Payload field (format depends on label definition: BNR, BCD, or discrete)

30-31

SSM

Sign/Status Matrix — indicates data validity, sign, or operational mode

32

Parity

Odd parity bit covering all 32 bits

This sample shows two transmission modes:

  • FIFO mode — you load one or more 32-bit ARINC words into the transmit FIFO, and the hardware sends them immediately in order. This is the simplest approach for on-demand transmission.

  • Scheduled mode — you preload message words into a dedicated message memory, then build a schedule that controls which words are transmitted and when, with configurable gap times between them. The schedule runs autonomously on the hardware. While the schedule is active, you can also inject asynchronous words.

This sample supports the following module types: AR1 (up to 12 channels), AR2 (2 channels). It also works with combination modules that include ARINC 429 functionality: CM2 (8 AR channels) and CM5 (8 AR channels).

For the receive side of ARINC 429 operations, see AR Receive. For interrupt-driven receive notification, see AR Interrupt Basic. Consult your AR module’s manual for hardware-specific specifications including FIFO depth, data rate timing, and channel count.

Prerequisites

Before running this sample, make sure you have:

  • An NAI board with an ARINC 429 module installed (AR1, AR2, or a combination module such as CM2 or CM5).

  • SSK 1.x installed on your development host.

  • The sample applications built. Refer to the SSK 1.x build instructions for your platform if you have not already compiled them.

  • For verifying transmitted data: an ARINC 429 receiver connected to the transmit channel’s bus (either an external device, a bus analyzer, or another channel on the same module configured for Rx using the AR Receive sample).

How to Run

Launch the AR_Transmit executable from your build output directory. On startup the application looks for a configuration file (default_ARXmit.txt). On the first run, this file will not exist — the application will present an interactive board menu where you configure a board connection, card index, and module slot. You can save this configuration so that subsequent runs skip the menu and connect automatically. Once connected, the application prompts you for a channel number and data rate, then presents a menu to select FIFO or Scheduled transmission mode.

Board Connection and Module Selection

Note
This startup sequence is common to all NAI sample applications. The board connection and module selection code shown here is not specific to ARINC 429. For details on board connection configuration, see the First Time Setup Guide.

The main() function (or AR_Transmit() on VxWorks) follows a standard SSK 1.x startup flow:

  1. Call naiapp_RunBoardMenu() to load a saved configuration file or present the interactive board menu. The configuration file (default_ARXmit.txt) is not included with the SSK — it is created when you save your connection settings from the board menu. On the first run, the menu will always appear.

  2. If the board connection succeeds, enter the main application loop by calling Run_AR_Transmit().

  3. After returning from the transmit loop, prompt the user to quit or restart.

  4. Close all open board connections with naiapp_access_CloseAllOpenCards().

#if defined (__VXWORKS__)
int32_t AR_Transmit(void)
#else
int32_t main(void)
#endif
{
   bool_t stop = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(CONFIG_FILE) == TRUE)
   {
      while (stop != TRUE)
      {
         Run_AR_Transmit();
      }

      printf("\nType Q to quit or Enter key to restart application:\n");
      stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   }

   naiapp_access_CloseAllOpenCards();
   return 0;
}
Important

Common Connection Errors

  • No board found — verify the board is powered on and connected. Check your Ethernet cable or PCI seating.

  • Connection timeout — confirm the board’s IP address matches your configuration. Ensure no firewall is blocking the connection.

  • Invalid card/module index — the card index is zero-based. Module numbers depend on the physical slot. Use the board menu to verify available modules.

  • Module not present — the selected slot does not contain an AR module. Verify the module is installed and recognized by the board firmware.

Program Structure

Application Parameters and Defaults

The sample defines default values that serve as prompts during interactive configuration. In your own application, you would set these values directly rather than prompting a user:

#define DEF_AR_CARD_INDEX      0
#define DEF_AR_MODULE          1
#define DEF_AR_XMIT_CHANNEL   1
#define DEF_AR_SCHED           0
#define DEF_AR_DATA_RATE       AR_SPEED_LOW
#define DEF_AR_XMIT_DATA_COUNT 1
  • DEF_AR_DATA_RATE — AR_SPEED_LOW selects 12.5 kHz (low speed); the alternative is AR_SPEED_HIGH for 100 kHz (high speed). These are the two data rates defined by ARINC 429.

  • DEF_AR_XMIT_DATA_COUNT — the default number of ARINC words to transmit per FIFO send operation.

The global AR_FIFO_Size variable is initialized to 255 but is updated at runtime by querying the actual FIFO depth of the installed module via naibrd_AR_GetMaxFifoCount().

Command Menu

The sample presents a two-command menu after channel configuration is complete:

Command Description

FIFO

Transmit ARINC words immediately using the FIFO buffer

SCHED

Transmit ARINC words according to a preloaded schedule

The menu system is a sample convenience — in your own code, call the same naibrd_AR_* API functions directly without the menu infrastructure.

Channel Configuration

Before entering either transmission mode, Run_AR_Transmit() configures the ARINC channel. This configuration sequence runs each time the user returns to the mode selection menu, ensuring the channel is in a known state. To set up an ARINC transmit channel in your own application, follow this sequence:

1. Reset the channel to clear any prior state:

check_status(naibrd_AR_ChannelReset(cardIndex, module, archan));

2. Disable both transmitter and receiver to prevent activity during configuration:

check_status(naibrd_AR_SetTxEnable(cardIndex, module, archan, AR_DISABLE));
check_status(naibrd_AR_SetRxEnable(cardIndex, module, archan, AR_DISABLE));

3. Set the data rate to either low speed (12.5 kHz) or high speed (100 kHz):

check_status(naibrd_AR_SetDataRate(cardIndex, module, archan, datarate));

The datarate value is AR_SPEED_LOW or AR_SPEED_HIGH. Both the transmitter and receiver on a given bus must use the same data rate.

4. Query the FIFO size and set the FIFO threshold to the maximum supported by the module:

moduleID = naibrd_GetModuleID(cardIndex, module);
AR_FIFO_Size = naibrd_AR_GetMaxFifoCount(moduleID);
check_status(naibrd_AR_SetTxFifoThreshold(cardIndex, module, archan, AR_FIFO_Size));

The FIFO threshold determines when the FIFO-almost-empty status flag is set. Setting it to the maximum FIFO depth means the flag will indicate when the FIFO is completely empty. Consult your module’s manual for the actual FIFO depth — it varies by module type.

5. Configure parity handling so that bit 32 of each transmitted word is treated as an odd parity bit:

check_status(naibrd_AR_SetParityAsData(cardIndex, module, archan, AR_PAR_ODD));

With AR_PAR_ODD, the hardware automatically computes and inserts the correct odd parity bit (bit 32) for each transmitted word. If you set AR_PAR_DATA, bit 32 is treated as a data bit and transmitted as-is — use this only if your application manages parity externally.

6. Set the inter-word transmission interval:

naibrd_AR_SetTxIntervalRate(cardIndex, module, archan, 6);

This controls the gap between consecutive ARINC words on the bus, in units defined by the module hardware. Consult your module’s manual for the mapping between the interval value and the actual time gap.

Important

Common Configuration Errors

  • NAI_ERROR_NOT_SUPPORTED — the selected channel number exceeds the channel count for this module type. AR2 modules have 2 channels; AR1 modules have up to 12.

  • Data rate mismatch — if you are transmitting to a receiver, both must be configured for the same data rate. A mismatch will cause the receiver to see no data or corrupted data.

  • Parity errors on the receiver — if the receiver expects odd parity but the transmitter is set to AR_PAR_DATA, the receiver will flag parity errors. Ensure both sides agree on parity handling.

FIFO Transmission Mode

FIFO mode is the simplest way to transmit ARINC 429 words. You load data into the transmit FIFO, and the hardware sends each word on the bus in the order it was loaded. This mode is well-suited for on-demand transmission where you control exactly when and what data is sent.

Enabling FIFO Mode

To configure the channel for immediate FIFO transmission, set the send mode and enable the transmitter:

check_status(naibrd_AR_SetTxSendMode(cardIndex, module, channel, AR_TX_SENDMODE_IMMED));
check_status(naibrd_AR_SetTxEnable(cardIndex, module, channel, AR_ENABLE));

AR_TX_SENDMODE_IMMED tells the hardware to transmit words as soon as they are written to the FIFO, without waiting for a schedule trigger.

Sending Data

To transmit ARINC words, call naibrd_AR_TransmitBuffer() with an array of 32-bit words. The sample generates incrementing test data, but in your own application each 32-bit value would be a properly formatted ARINC 429 word with label, SDI, data, SSM, and parity fields.

uint32_t SendData[255];
int32_t nNumWordsSent;

/* Fill SendData with ARINC words to transmit */
check_status(naibrd_AR_TransmitBuffer(cardIndex, module, channel, dataIndex, SendData, &nNumWordsSent));

Parameters:

  • cardIndex, module, channel — identify the target transmit channel.

  • dataIndex — the number of words to send from the SendData array (up to AR_FIFO_Size).

  • SendData — array of 32-bit ARINC words to transmit.

  • nNumWordsSent — output parameter indicating how many words were actually accepted into the FIFO.

Handling Large Transfers

If you need to transmit more words than the FIFO can hold, break the transfer into blocks of AR_FIFO_Size and wait between blocks for the FIFO to drain. The sample demonstrates this pattern:

blockCnt = nNumWordsToSend / AR_FIFO_Size;
if (blockCnt * AR_FIFO_Size < nNumWordsToSend)
   blockCnt++;

dataCnt = 0;
for (i = 0; i < blockCnt; i++)
{
   dataIndex = 0;
   do
   {
      SendData[dataIndex++] = (uint32_t)increment++;
      dataCnt++;
   } while ((dataIndex < AR_FIFO_Size) && (dataCnt < nNumWordsToSend));

   check_status(naibrd_AR_TransmitBuffer(cardIndex, module, channel, dataIndex, SendData, &nNumWordsSent));

   naibrd_Wait(1000000);  /* Wait for FIFO to drain before loading next block */
}

The naibrd_Wait(1000000) call inserts a 1-second delay between blocks. This is necessary because writing to the FIFO while it is still full will cause data to be dropped. In a production application, you can poll the FIFO status registers instead of using a fixed delay to achieve faster throughput.

Disabling the Transmitter

After transmission is complete, disable the transmitter to release the bus:

check_status(naibrd_AR_SetTxEnable(cardIndex, module, channel, AR_DISABLE));
Important

Common FIFO Mode Errors

  • FIFO overflow / words dropped — you attempted to write more words than the FIFO can hold without waiting for it to drain. Break large transfers into blocks and wait between them.

  • nNumWordsSent less than requested — the FIFO did not have room for all the words. Wait for the FIFO to empty and retry the remaining words.

  • No data on the bus — verify the transmitter is enabled (naibrd_AR_SetTxEnable) and the send mode is set to AR_TX_SENDMODE_IMMED. Check physical cabling.

Scheduled Transmission Mode

Scheduled mode provides autonomous, hardware-driven transmission. You preload ARINC words and gap times into a message memory, then define a schedule that controls the transmission sequence. Once triggered, the schedule runs on the hardware without further software intervention. This mode is ideal for periodic or cyclic data transmission patterns typical in avionics systems.

Enabling Scheduled Mode

Set the send mode to scheduled and enable the transmitter:

check_status(naibrd_AR_SetTxSendMode(Card, nMod, nChan, AR_TX_SENDMODE_SCHED));
check_status(naibrd_AR_SetTxEnable(Card, nMod, nChan, AR_ENABLE));

Loading Message Memory

Message memory holds the 32-bit ARINC words and gap time values that the schedule will reference by address. To load a word into message memory, call naibrd_AR_WrTxMsgMem() with the address and data:

/* Load ARINC message words */
nMsgAddr = 0;
uiMsgData = 0x55555555;
check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));

nMsgAddr = 1;
uiMsgData = 0xAAAAAAAA;
check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));

The sample loads eight message words at addresses 0-7 and two gap time values at addresses 8-9:

Address Value Purpose

0

0x55555555

Message word

1

0xAAAAAAAA

Message word

2

0xABCDEF55

Message word

3

0x987654EE

Message word

4

0x3210FD07

Message word

5

0x555555EE

Message word

6

0xAAAAAA0F

Message word

7

0xFFFFFFFF

Message word

8

0x00001234

Gap time (variable gap)

9

0x00002564

Gap time (fixed gap)

Message memory supports addresses 0-255. In your own application, each message word should be a properly formatted ARINC 429 word. The test values shown here are arbitrary patterns used for verification.

Building the Schedule

Schedule memory defines the transmission sequence. Each schedule entry is a 16-bit command word consisting of a command type ORed with a message memory address. The available schedule command types are:

Command Type Description

AR_TX_SCHED_MESSAGE

Transmit the ARINC word at the specified message memory address

AR_TX_SCHED_GAP

Insert a variable gap using the time value at the specified message memory address

AR_TX_SCHED_FIXEDGAP

Insert a fixed gap using the time value at the specified message memory address

AR_TX_SCHED_JUMP

Jump to the specified schedule memory address (for looping)

AR_TX_SCHED_STOP

Stop schedule execution

To write a schedule entry, call naibrd_AR_WrTxSchMem():

/* Schedule entry 0: transmit message at address 0 */
nMsgAddr = 0;
nSchedAddr = 0;
usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

/* Schedule entry 1: insert fixed gap using time at address 9 */
nMsgAddr = 9;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_FIXEDGAP | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

The sample builds a 18-entry schedule that transmits all eight message words with alternating gap and fixed-gap pauses between them:

Schedule Addr Command Action

0

MESSAGE | 0

Transmit 0x55555555

1

FIXEDGAP | 9

Fixed gap (0x00002564)

2

MESSAGE | 1

Transmit 0xAAAAAAAA

3

GAP | 8

Variable gap (0x00001234)

4

MESSAGE | 2

Transmit 0xABCDEF55

5

FIXEDGAP | 9

Fixed gap (0x00002564)

6

MESSAGE | 3

Transmit 0x987654EE

7

GAP | 8

Variable gap (0x00001234)

8

MESSAGE | 4

Transmit 0x3210FD07

9

FIXEDGAP | 9

Fixed gap (0x00002564)

10

MESSAGE | 5

Transmit 0x555555EE

11

GAP | 8

Variable gap (0x00001234)

12

MESSAGE | 6

Transmit 0xAAAAAA0F

13

FIXEDGAP | 9

Fixed gap (0x00002564)

14

MESSAGE | 7

Transmit 0xFFFFFFFF

15

GAP | 8

Variable gap (0x00001234)

16

JUMP | 3

Jump back to schedule address 3 (loop)

17

STOP | 0

Stop the schedule

Note the JUMP command at address 16: it causes the schedule to loop back to address 3, creating a repeating cycle that skips the first message and its gap. The STOP at address 17 is placed after the jump and would only execute if the jump entry were modified at runtime. Schedule memory supports addresses 0-511.

Starting and Stopping the Schedule

To begin schedule execution, trigger the transmitter:

check_status(naibrd_AR_SetTxSendTrigger(Card, nMod, nChan));

The hardware begins executing the schedule from address 0 and continues autonomously until it hits a STOP command or you explicitly stop it.

To stop the schedule:

check_status(naibrd_AR_SetTxStop(Card, nMod, nChan));

After stopping, disable the transmitter:

check_status(naibrd_AR_SetTxEnable(Card, nMod, nChan, AR_DISABLE));

Sending Asynchronous Words During a Schedule

While a schedule is running, you can inject additional ARINC words that are transmitted between scheduled entries. The sample demonstrates this by sending an async word when the user presses a key:

check_status(naibrd_AR_WrTxAsyncWd(Card, nMod, nChan, 0x11111111));

The async word (0x11111111 in this example) is inserted into the transmission stream at the next available gap in the schedule. This is useful for sending event-driven or aperiodic data while maintaining a cyclic scheduled transmission pattern.

Important

Common Scheduled Mode Errors

  • Schedule does not start — verify the transmitter is enabled and the send mode is set to AR_TX_SENDMODE_SCHED before calling naibrd_AR_SetTxSendTrigger().

  • Schedule runs once and stops — check that your schedule includes a JUMP command to create a loop. Without a jump, the schedule will execute linearly until it hits a STOP or runs past the last defined entry.

  • Unexpected message ordering — verify that message memory addresses in your schedule entries match the addresses where you loaded the corresponding data with naibrd_AR_WrTxMsgMem().

  • Async words not appearing — async words are only transmitted during schedule gaps. If the schedule has no gap entries, async words may be significantly delayed or appear to be missing.

Troubleshooting Reference

Note
This section summarizes errors covered in the preceding sections. Consult your AR module’s manual for hardware-specific diagnostics and status register definitions.
Error / Symptom Possible Causes Suggested Resolution

No board found at startup

Board not powered, cable disconnected, wrong IP address

Verify power, cabling, and network configuration. Re-run the board menu to reconfigure.

Module not present

Selected slot does not contain an AR module

Verify the module is physically installed. Use the board menu to check available modules.

NAI_ERROR_NOT_SUPPORTED

Channel number exceeds module’s channel count; feature not available on this module type

Check the channel count for your module type (AR1: up to 12, AR2: 2, CM2/CM5: 8).

No data on the bus (FIFO mode)

Transmitter not enabled; send mode not set to immediate; physical bus not connected

Call naibrd_AR_SetTxEnable() with AR_ENABLE and naibrd_AR_SetTxSendMode() with AR_TX_SENDMODE_IMMED. Check cabling.

FIFO overflow / data dropped

Writing more words than the FIFO can hold without draining

Break large transfers into blocks of AR_FIFO_Size and wait between blocks. Poll the FIFO status or use naibrd_Wait().

nNumWordsSent less than requested

FIFO partially full when the write was attempted

Wait for the FIFO to drain and retry the remaining words.

Receiver reports parity errors

Transmitter and receiver parity settings do not match

Ensure both sides use the same parity mode (AR_PAR_ODD or AR_PAR_DATA).

Data rate mismatch (receiver sees no data)

Transmitter and receiver configured for different speeds

Set both to AR_SPEED_LOW (12.5 kHz) or both to AR_SPEED_HIGH (100 kHz).

Schedule does not start

Transmitter not enabled; send mode not set to scheduled

Call naibrd_AR_SetTxEnable() and naibrd_AR_SetTxSendMode() with AR_TX_SENDMODE_SCHED before triggering.

Schedule runs once and stops

No JUMP command in the schedule to create a loop

Add an AR_TX_SCHED_JUMP entry pointing to the desired restart address.

Wrong messages in schedule output

Message memory address mismatch between WrTxMsgMem and WrTxSchMem calls

Verify that schedule entries reference the correct message memory addresses.

Async words not appearing during schedule

Schedule has no gap entries; async words are queued but not transmitted

Add AR_TX_SCHED_GAP or AR_TX_SCHED_FIXEDGAP entries to your schedule.

Full Source

Full Source — AR_Transmit.c (SSK 1.x)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

/* Common Sample Program include files */
#include "include/naiapp_boardaccess_menu.h"
#include "include/naiapp_boardaccess_query.h"
#include "include/naiapp_boardaccess_access.h"
#include "include/naiapp_boardaccess_display.h"
#include "include/naiapp_boardaccess_utils.h"
#include "nai_ar_utils.h"
#include "nai_ar_utils.h"

/* naibrd include files */
#include "nai.h"
#include "naibrd.h"
#include "functions/naibrd_ar.h"

static const int8_t *CONFIG_FILE = (int8_t *)"default_ARXmit.txt";

/* Function prototypes */
void Run_AR_Transmit(void);
nai_status_t AR_TxFIFO(int32_t paramCount, int32_t* p_params);
nai_status_t AR_TxSchedule(int32_t paramCount, int32_t* p_params);

/****** Command Table *******/
enum arfuncgen_commands
{
   AR_FUNCGEN_CMD_TX_FIFO,
   AR_FUNCGEN_CMD_TX_SCHEDULE,
   AR_FUNCGEN_CMD_COUNT
};

/****** Command Tables *******/
static naiapp_cmdtbl_params_t AR_FuncGenMenuCmds[] =
{
   {"FIFO  ", "AR Transmit FIFO Mode      ", AR_FUNCGEN_CMD_TX_FIFO,     AR_TxFIFO},
   {"SCHED ", "AR Transmit Scheduled Mode ", AR_FUNCGEN_CMD_TX_SCHEDULE, AR_TxSchedule}
};

#define DEF_AR_CARD_INDEX                 0
#define DEF_AR_MODULE                     1
#define DEF_AR_XMIT_CHANNEL               1
#define DEF_AR_SCHED                      0
#define DEF_AR_DATA_RATE                  AR_SPEED_LOW
#define DEF_AR_XMIT_DATA_COUNT            1

/***** Global Variables *****/
static int32_t AR_FIFO_Size = 255;

/**************************************************************************************************************/
/**
<summary>
The purpose of the AR_Transmit is to illustrate the methods to call in the naibrd library to configure
the ARINC channel to transmit ARINC messages in FIFO or scheduled mode.

The following system configuration routines from the nai_sys_cfg.c file are called to assist with the configuration
setup for this program prior to calling the naibrd 1553 routines.
 - ClearDeviceCfg
 - QuerySystemCfg
 - DisplayDeviceCfg
 - GetBoardSNModCfg
 - SaveDeviceCfg

Note, the AR_Transmit application can run in conjunction with the AR_Receive, AR_ReceiveInterruptEther or
AR_ReceiveInterruptBus applications to illustrate ARINC transmit and receive operations together with the NAI ARINC module.
</summary>
*/
/**************************************************************************************************************/
#if defined (__VXWORKS__)
int32_t AR_Transmit(void)
#else
int32_t main(void)
#endif
{
   bool_t stop = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(CONFIG_FILE) == TRUE)
   {
      while (stop != TRUE)
      {
         Run_AR_Transmit();
      }

      printf("\nType Q to quit or Enter key to restart application:\n");
      stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   }

   naiapp_access_CloseAllOpenCards();

   return 0;
}

nai_status_t AR_TxSchedule(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   int32_t nMsgAddr, nSchedAddr, nJumpSchedAddr;
   uint32_t uiMsgData, uiGapTime;
   uint16_t usSchedData;
   p_naiapp_AppParameters_t p_ad_params = (p_naiapp_AppParameters_t)p_params;
   int32_t Card = p_ad_params->cardIndex;
   int32_t nMod = p_ad_params->module;
   int32_t nChan = p_ad_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   /* Set Scheduled Transmission mode */
   check_status(naibrd_AR_SetTxSendMode(Card, nMod, nChan, AR_TX_SENDMODE_SCHED));
   /* Enable Transmitter */
   check_status(naibrd_AR_SetTxEnable(Card, nMod, nChan, AR_ENABLE));

   /************************************************************************/
   /* Initialize Message Memory (0 - 255) with Message Words and Gap Times */
   /************************************************************************/
   printf("Initializing Message Memory\n");
   /* Put 32-bit Message Word into Message Memory at address 0 */
   nMsgAddr = 0;
   uiMsgData = 0x55555555;
   check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));

   /* Put 32-bit Message Word into Message Memory at address 1 */
   nMsgAddr = 1;
   uiMsgData = 0xaaaaaaaa;
   check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));

   /* Put 32-bit Message Word into Message Memory at address 2 */
   nMsgAddr = 2;
   uiMsgData = 0xABCDEF55;
   check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));

   /* Put 32-bit Message Word into Message Memory at address 3 */
   nMsgAddr = 3;
   uiMsgData = 0x987654EE;
   check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));

   /* Put 32-bit Message Word into Message Memory at address 4 */
   nMsgAddr = 4;
   uiMsgData = 0x3210FD07;
   check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));

   /* Put 32-bit Message Word into Message Memory at address 5 */
   nMsgAddr = 5;
   uiMsgData = 0x555555EE;
   check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));

   /* Put 32-bit Message Word into Message Memory at address 6 */
   nMsgAddr = 6;
   uiMsgData = 0xAAAAAA0F;
   check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));

   /* Put 32-bit Message Word into Message Memory at address 7 */
   nMsgAddr = 7;
   uiMsgData = 0xFFFFFFFF;
   check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));

   /* Put Gap Time into Message Memory at address 8 */
   nMsgAddr = 8;
   uiGapTime = 0x00001234;
   check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiGapTime));

   /* Put Fixed Gap Time into Message Memory at address 9 */
   nMsgAddr = 9;
   uiGapTime = 0x00002564;
   check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiGapTime));

   /***********************************************************/
   /* Build and Download Schedule - Schedule Memory (0 - 511) */
   /***********************************************************/
   printf("Building and Downloading Schedule\n");
   /* Put Schedule Message Command into Schedule Memory at address 0 */
   printf("\nSchedule 0 is Message    0x55555555\n");
   nMsgAddr = 0;
   nSchedAddr = 0;
   usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Fixed Gap Command into next Schedule Memory */
   printf("Schedule 1 is Fixed Gap  0x00002564\n");
   nMsgAddr = 9;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_FIXEDGAP | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Message Command into next Schedule Memory */
   printf("Schedule 2 is Message    0xAAAAAAAA\n");
   nMsgAddr = 1;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Gap Command into next Schedule Memory */
   printf("Schedule 3 is Gap        0x00001234\n");
   nMsgAddr = 8;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_GAP | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Message Command into Schedule Memory at address 0 */
   printf("Schedule 4 is Message    0xABCDEF55\n");
   nMsgAddr = 2;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Fixed Gap Command into next Schedule Memory */
   printf("Schedule 5 is Fixed Gap  0x00002564\n");
   nMsgAddr = 9;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_FIXEDGAP | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Message Command into next Schedule Memory */
   printf("Schedule 6 is Message    0x987654EE\n");
   nMsgAddr = 3;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Gap Command into next Schedule Memory */
   printf("Schedule 7 is Gap        0x00001234\n");
   nMsgAddr = 8;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_GAP | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Message Command into Schedule Memory at address 0 */
   printf("Schedule 8 is Message    0x3210FD07\n");
   nMsgAddr = 4;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Fixed Gap Command into next Schedule Memory */
   printf("Schedule 9 is Fixed Gap  0x00002564\n");
   nMsgAddr = 9;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_FIXEDGAP | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Message Command into next Schedule Memory */
   printf("Schedule 10 is Message   0x555555EE\n");
   nMsgAddr = 5;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Gap Command into next Schedule Memory */
   printf("Schedule 11 is Gap       0x00001234\n");
   nMsgAddr = 8;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_GAP | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Message Command into Schedule Memory at address 0 */
   printf("Schedule 12 is Message   0xAAAAAA0F\n");
   nMsgAddr = 6;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Fixed Gap Command into next Schedule Memory */
   printf("Schedule 13 is Fixed Gap 0x00002564\n");
   nMsgAddr = 9;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_FIXEDGAP | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Message Command into next Schedule Memory */
   printf("Schedule 14 is Message   0xFFFFFFFF\n");
   nMsgAddr = 7;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Gap Command into next Schedule Memory */
   printf("Schedule 15 is Gap       0x00001234\n");
   nMsgAddr = 8;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_GAP | nMsgAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Put Schedule Jump Command into next Schedule Memory */
   printf("Schedule 4 is Jump to   Schedule 0\n");
   nJumpSchedAddr = 3;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_JUMP | nJumpSchedAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   printf("Schedule 16 is Stop\n");
   nJumpSchedAddr = 0;
   nSchedAddr++;
   usSchedData = (uint16_t)(AR_TX_SCHED_STOP | nJumpSchedAddr);
   check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));

   /* Start schedule mode */
   printf("\nStarting Schedule\n");
   check_status(naibrd_AR_SetTxSendTrigger(Card, nMod, nChan));

   while (!bQuit)
   {
      printf("\nType A to send Async Data (0x11111111) or %c to quit (default: A) : ", NAI_QUIT_CHAR);
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
         check_status(naibrd_AR_WrTxAsyncWd(Card, nMod, nChan, 0x11111111));   /* Send Async Data */
   }

   /* Stop schedule mode */
   printf("\nStopping Schedule\n");
   check_status(naibrd_AR_SetTxStop(Card, nMod, nChan));

   /* Disable transmitter */
   check_status(naibrd_AR_SetTxEnable(Card, nMod, nChan, AR_DISABLE));

   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}

nai_status_t AR_TxFIFO(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   int32_t nNumWordsToSend = 1;
   int32_t nNumWordsSent;
   int32_t i, j;
   int32_t blockCnt, dataCnt, dataIndex;
   int32_t increment = 0x55555555;
   uint32_t SendData[255];
   p_naiapp_AppParameters_t p_ad_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_ad_params->cardIndex;
   int32_t module = p_ad_params->module;
   int32_t channel = p_ad_params->channel;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   /* Set Immediate FIFO Transmission mode */
   check_status(naibrd_AR_SetTxSendMode(cardIndex, module, channel, AR_TX_SENDMODE_IMMED));
   /* Enable transmitter */
   check_status(naibrd_AR_SetTxEnable(cardIndex, module, channel, AR_ENABLE));

   while (!bQuit)
   {
      /* Query for the number of data words to send */
      bQuit = GetARTransmitDataCount(DEF_AR_XMIT_DATA_COUNT, &nNumWordsToSend);
      if (!bQuit)
      {
         /* Break up the FIFO updates to blocks of AR_FIFOSize */
         blockCnt = nNumWordsToSend / AR_FIFO_Size;
         if (blockCnt * AR_FIFO_Size < nNumWordsToSend)
            blockCnt++;

         dataCnt = 0;
         for (i = 0; i < blockCnt; i++)
         {
            dataIndex = 0;
            do
            {
               SendData[dataIndex++] = (uint32_t)increment++; /* incremental data */
               dataCnt++;
            } while ((dataIndex < AR_FIFO_Size) && (dataCnt < nNumWordsToSend));

            printf("\nSending %d words ...\n", dataIndex);
            for (j = 0; j < dataIndex; j++)
               printf("Sent 0x%08X\n", SendData[j]);

            check_status(naibrd_AR_TransmitBuffer(cardIndex, module, channel, dataIndex, SendData, &nNumWordsSent)); /* send data */
            printf(" %d words sent. Total words sent = %d\n", nNumWordsSent, dataCnt);

            naibrd_Wait(1000000);  /* Delay is necessary to allow the FIFO buffer to empty before filling it up with more data */
         }
      }
   }

   /* Disable transmitter */
   check_status(naibrd_AR_SetTxEnable(cardIndex, module, channel, AR_DISABLE));

   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
Run_AR_Transmit queries the user for the card, module and channel to configure as the ARINC transmitter
as well as the data rate (high (100KHz) or low (12.5KHz)) and the type of message transmission (FIFO or scheduled).
Methods in the naibrd library are invoked to configure the ARINC channel.
Once the ARINC channel is configured and running, the user can:
1) In FIFO mode, enter the number of words to transmit. Note, the data sent is an incremental value.
2) In Scheduled mode, transmit an async ARINC data word.
</summary>
*/
/**************************************************************************************************************/
void Run_AR_Transmit(void)
{
   int32_t cardIndex, module, archan;
   nai_ar_datarate_t datarate;
   uint32_t moduleID;
   bool_t bQuit = FALSE;
   bool_t bContinue, bCmdFound;
   int32_t cmd;
   naiapp_AppParameters_t  ar_params;
   p_naiapp_AppParameters_t ar_transmit_params = &ar_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   bQuit = GetARCfg(DEF_AR_CARD_INDEX, DEF_AR_MODULE, DEF_AR_XMIT_CHANNEL, &cardIndex, &module, &archan);
   ar_transmit_params->cardIndex = cardIndex;
   ar_transmit_params->module = module;
   ar_transmit_params->channel = archan;

   if (!bQuit)
   {
      /* Get Data Rate */
      bQuit = GetARINCDataRate(DEF_AR_DATA_RATE, &datarate);
      if (!bQuit)
      {
         bContinue = TRUE;

         naiapp_utils_LoadParamMenuCommands(AR_FUNCGEN_CMD_COUNT, AR_FuncGenMenuCmds);
         while (bContinue)
         {
            /* Reset the channel */
            check_status(naibrd_AR_ChannelReset(cardIndex, module, archan));
            /* Disable Tx/Rx */
            check_status(naibrd_AR_SetTxEnable(cardIndex, module, archan, AR_DISABLE));
            check_status(naibrd_AR_SetRxEnable(cardIndex, module, archan, AR_DISABLE));
            /* Set the transmission speed */
            check_status(naibrd_AR_SetDataRate(cardIndex, module, archan, datarate));
            /* Set the Tx Fifo Threshold to the maximum size of the FIFO */
            moduleID = naibrd_GetModuleID(cardIndex, module);
            AR_FIFO_Size = naibrd_AR_GetMaxFifoCount(moduleID);
            check_status(naibrd_AR_SetTxFifoThreshold(cardIndex, module, archan, AR_FIFO_Size));
            /* Set the Parity Disable bit to cause the ARINC bit 32 to be treated as an odd parity bit */
            check_status(naibrd_AR_SetParityAsData(cardIndex, module, archan, AR_PAR_ODD));

            naibrd_AR_SetTxIntervalRate(cardIndex, module, archan, 6);

            naiapp_display_ParamMenuCommands((int8_t *)"AR Receive Mode Menu");
            printf("\nType AR command or %c to quit : ", NAI_QUIT_CHAR);
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            if (!bQuit)
            {
               if (inputResponseCnt > 0)
               {
                  bCmdFound = naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
                  if (bCmdFound)
                  {
                     switch (cmd)
                     {
                     case AR_FUNCGEN_CMD_TX_FIFO:
                     case AR_FUNCGEN_CMD_TX_SCHEDULE:
                        AR_FuncGenMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)ar_transmit_params);

                        break;
                     default:
                        printf("Invalid command entered\n");
                        break;
                     }
                  }
                  else
                     printf("Invalid command entered\n");
               }
            }
            else
               bContinue = FALSE;
         }
      }
   }
   return;
}

Help Bot

X