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

M1760 RT Prog EEPROM

M1760 RT Prog EEPROM Sample Application (SSK 2.x)

Overview

The M1760 RT Prog EEPROM sample application demonstrates how to configure a MIL-STD-1760 channel as a Remote Terminal (RT), set up specific subaddresses with data blocks, and save the complete RT configuration to EEPROM for auto-initialization on power-up using the NAI Software Support Kit (SSK 2.x).

Unlike the M1760 EEPROM Copy sample which copies the current (possibly arbitrary) state to EEPROM, this sample builds a specific RT configuration first: it legalizes subaddresses 2 and 15 for Rx messages, creates a Tx buffer on subaddress 23 with initial data, then saves this configuration to EEPROM. On subsequent power-ups, the channel will auto-initialize as an RT with these subaddresses configured and will respond with clear status (within 100 ms from power-up) to messages on these subaddresses.

This sample works with FTJ and FTK modules.

For detailed 1553/1760 protocol specifications, see the FTA-FTF Manual.

For the SSK 1.x version, see M1760 RT Program EEPROM (SSK 1.x).

Prerequisites

Before running this sample, make sure you have:

  • An NAI board with a 1760 module installed (FTJ or FTK).

  • SSK 2.x installed on your development host.

  • The sample applications built. Refer to the SSK 2.x Software Development Guide for platform-specific build instructions.

How to Run

Launch the m1760_rt_prog_eeprom executable from your build output directory. On startup the application looks for a configuration file (default_1760_RTProgramEEPROM.txt). Once connected, the application prompts for RT channel, RT address, and logical device number. It configures the RT, starts and immediately stops it (required for EEPROM copy), then copies the configuration to EEPROM.

Board Connection and Module Selection

Note
This startup sequence is common to all NAI sample applications.

The main() function follows the standard SSK 2.x startup flow: board menu, card index query, module selection, and module ID retrieval.

Program Structure

Entry Point

The Run_M1760_RT_Program_EEPROM() function configures the RT channel and address via Get1553RTCfg(), opens the device, initializes as RT, creates data blocks, briefly starts and stops the RT, then performs the EEPROM copy.

Application Flow

  1. Initialize as RT with naibrd_1553_Init().

  2. Read and display the RT address with naibrd_1553_RtGetAddr().

  3. Create Rx double buffers for subaddresses 2 and 15.

  4. Create Tx single buffers for subaddress 23 with initial data.

  5. Start and immediately stop the RT.

  6. Unlock EEPROM and initiate copy.

  7. Poll until device ready.

RT Configuration for EEPROM

Rx Subaddresses

/* Subaddress 2: Rx double buffer */
swResult = naibrd_1553_RtDataBlkCreate(DevNum, DBLK_SA2, NAIBRD_1553_RT_DATABLOCK_DOUBLE, NULL, 0);
swResult = naibrd_1553_RtDataBlkMapToSA(DevNum, DBLK_SA2, 2, NAIBRD_1553_RT_MESSAGE_TYPE_RX,
   NAIBRD_1553_RT_DATABLOCK_IRQ_NONE, 1);

/* Subaddress 15: Rx double buffer */
swResult = naibrd_1553_RtDataBlkCreate(DevNum, DBLK_SA15, NAIBRD_1553_RT_DATABLOCK_DOUBLE, NULL, 0);
swResult = naibrd_1553_RtDataBlkMapToSA(DevNum, DBLK_SA15, 15, NAIBRD_1553_RT_MESSAGE_TYPE_RX,
   NAIBRD_1553_RT_DATABLOCK_IRQ_NONE, 1);

Tx Subaddress with Initial Data

/* Subaddress 23: Two Tx single buffers for ping-pong */
swResult = naibrd_1553_RtDataBlkCreate(DevNum, DBLK_SA23_1, NAIBRD_1553_RT_DATABLOCK_SINGLE_32, NULL, 0);
swResult = naibrd_1553_RtDataBlkCreate(DevNum, DBLK_SA23_2, NAIBRD_1553_RT_DATABLOCK_SINGLE_32, NULL, 0);
swResult = naibrd_1553_RtDataBlkMapToSA(DevNum, DBLK_SA23_1, 23, NAIBRD_1553_RT_MESSAGE_TYPE_TX,
   NAIBRD_1553_RT_DATABLOCK_IRQ_NONE, 1);

/* Load initial Tx data */
for (i = 0; i < 32; i++)
   txData[i] = (uint16_t)(0xBEEF + i);
swResult = naibrd_1553_RtDataBlkWrite(DevNum, DBLK_SA23_1, txData, 32, 0);

The initial Tx data (0xBEEF through 0xBF0E) will be stored in EEPROM and available immediately after power-up.

RT Start/Stop Before EEPROM Copy

The RT must be started and stopped before the EEPROM copy to ensure the internal state machine is properly initialized:

swResult = naibrd_1553_RtStart(DevNum);
swResult = naibrd_1553_RtStop(DevNum);
Important

The RT must not be running when the EEPROM copy is performed. Starting and immediately stopping the RT initializes the hardware state without leaving the RT active.

EEPROM Copy Sequence

swResult = naibrd_1760_SetEEPROMUnlock(DevNum);
swResult = naibrd_1760_SetEECOPY(DevNum, NAI_TRUE);
naibrd_msDelay(10);
swResult = naibrd_1760_SetEECOPY(DevNum, NAI_FALSE);

/* Wait for completion */
do
{
   naibrd_msDelay(1000);
   swResult = naibrd_1760_GetDeviceReady(DevNum, &ready);
} while (!ready);

After the copy completes, the module will auto-initialize with this RT configuration on every subsequent power-up.

Troubleshooting Reference

Error / Symptom Possible Causes Suggested Resolution

Module not supported

Module is not FTJ or FTK

Only 1760 modules support EEPROM programming

naibrd_1760_SetEEPROMUnlock fails

Device not properly initialized

Ensure naibrd_1553_Init and RT start/stop completed

Device ready never goes high

EEPROM hardware fault

Power cycle the module and retry

RT does not auto-initialize after reboot

EEPROM copy did not complete, wrong configuration saved

Re-run the sample and wait for "Copy Complete" message

naibrd_1553_Open returns non-zero

Channel already open, invalid indices

Verify indices, ensure no other application holds the channel

RT address incorrect after auto-init

RT address read from hardware pins at boot

Verify hardware address pins or reconfigure with software address

Full Source

Full Source — m1760_rt_prog_eeprom.c (SSK 2.x)
/* nailib include files */
#include "nai_libs/nailib/include/naitypes.h"
#include "nai_libs/nailib/include/nailib.h"
#include "nai_libs/nailib/include/nailib_utils.h"

/* naibrd include files */
#include "nai_libs/naibrd/include/nai.h"
#include "nai_libs/naibrd/include/naibrd.h"
#include "nai_libs/naibrd/include/functions/naibrd_1553.h"
#include "nai_libs/naibrd/include/functions/naibrd_1760.h"

/* naiif include files */
#include "nai_libs/naiif/include/naiif_stdio.h"

/* Common 1553 Sample Program include files */
#include "nai_sample_apps/naiapp_src/board_modules/1553/m1553_common_utils/m1553_common_utils.h"

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

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

static bool_t Run_M1760_RT_Program_EEPROM(int32_t cardIndex, int32_t module, uint32_t modid);

#define DBLK_SA2        1
#define DBLK_SA15       2
#define DBLK_SA23_1     3
#define DBLK_SA23_2     4

#define DEF_RT_CHANNEL     1
#define DEF_RT_DEV_NUM     1
#define DEF_RT_ADDRESS     1

#if defined (__VXWORKS__)
int32_t M1760_RT_Program_EEPROM(void)
#else
int32_t main(void)
#endif
{
   bool_t bQuit = NAI_FALSE;
   int32_t cardIndex = -1;
   int32_t module = 0;
   int32_t moduleCount = 0;
   uint32_t modid = 0u;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(CONFIG_FILE) == NAI_TRUE)
   {
      while (!bQuit)
      {
         bQuit = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (bQuit != NAI_TRUE)
         {
            bQuit = naibrd_GetModuleCount(cardIndex, &moduleCount);
            bQuit = naiapp_query_ModuleNumber(moduleCount, 1, &module);
            if (bQuit != NAI_TRUE)
            {
               check_status(naibrd_GetModuleName(cardIndex, module, &modid));
               if (modid != 0)
                  Run_M1760_RT_Program_EEPROM(cardIndex, module, modid);
            }
         }
         naiif_printf("Type %c to exit program or Enter key to restart application: ", NAI_QUIT_CHAR);
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      }
   }

   naiif_printf("Type any key to exit the program: ");
   naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   naiapp_access_CloseAllOpenCards();
   return 0;
}

static bool_t Run_M1760_RT_Program_EEPROM(int32_t cardIndex, int32_t module, uint32_t modid)
{
   bool_t bQuit = NAI_FALSE;
   int32_t rtchan;
   naibrd_1553_rt_address_t rtaddr;
   int16_t DevNum = 0;
   int32_t swResult;
   uint16_t usData;
   uint16_t txData[32];
   int32_t i;
   bool_t ready;

   bQuit = Get1553RTCfg(modid, DEF_RT_CHANNEL, DEF_RT_ADDRESS, &rtchan, &rtaddr);
   if (bQuit) return bQuit;

   bQuit = Get1553LogicalDevNum(DEF_RT_DEV_NUM, &DevNum);
   if (bQuit) return bQuit;

   swResult = naibrd_1553_Open(cardIndex, module, rtchan, DevNum);
   if (swResult) { naiif_printf("Error: naibrd_1553_Open  %d", swResult); return NAI_TRUE; }

   swResult = naibrd_1553_Init(DevNum, NAIBRD_1553_ACCESS_CARD, NAIBRD_1553_MODE_RT, 0, 0, 0);
   if (swResult != 0) { naiif_printf("Error: naibrd_1553_Initialize  %d", swResult); return NAI_TRUE; }

   swResult = naibrd_1553_RtGetAddr(DevNum, &usData);
   naiif_printf("RT Address set to %d\r\n\r\n", usData);

   /* Create Rx double buffers for SA 2 and SA 15 */
   naibrd_1553_RtDataBlkCreate(DevNum, DBLK_SA2, NAIBRD_1553_RT_DATABLOCK_DOUBLE, NULL, 0);
   naibrd_1553_RtDataBlkMapToSA(DevNum, DBLK_SA2, 2, NAIBRD_1553_RT_MESSAGE_TYPE_RX, NAIBRD_1553_RT_DATABLOCK_IRQ_NONE, 1);

   naibrd_1553_RtDataBlkCreate(DevNum, DBLK_SA15, NAIBRD_1553_RT_DATABLOCK_DOUBLE, NULL, 0);
   naibrd_1553_RtDataBlkMapToSA(DevNum, DBLK_SA15, 15, NAIBRD_1553_RT_MESSAGE_TYPE_RX, NAIBRD_1553_RT_DATABLOCK_IRQ_NONE, 1);

   /* Create Tx single buffers for SA 23 */
   naibrd_1553_RtDataBlkCreate(DevNum, DBLK_SA23_1, NAIBRD_1553_RT_DATABLOCK_SINGLE_32, NULL, 0);
   naibrd_1553_RtDataBlkCreate(DevNum, DBLK_SA23_2, NAIBRD_1553_RT_DATABLOCK_SINGLE_32, NULL, 0);
   naibrd_1553_RtDataBlkMapToSA(DevNum, DBLK_SA23_1, 23, NAIBRD_1553_RT_MESSAGE_TYPE_TX, NAIBRD_1553_RT_DATABLOCK_IRQ_NONE, 1);

   /* Load Tx buffer with initial data */
   for (i = 0; i < 32; i++) txData[i] = (uint16_t)(0xBEEF + i);
   naibrd_1553_RtDataBlkWrite(DevNum, DBLK_SA23_1, txData, 32, 0);

   /* Start and stop RT (required before EEPROM copy) */
   naibrd_1553_RtStart(DevNum);
   naibrd_1553_RtStop(DevNum);

   /* Copy to EEPROM */
   swResult = naibrd_1760_SetEEPROMUnlock(DevNum);
   naiif_printf("\r\nSerial EEPROM Unlock Successful.");

   naibrd_1760_SetEECOPY(DevNum, NAI_TRUE);
   naiif_printf("\r\nDriving EECOPY input high.");
   naibrd_msDelay(10);
   naibrd_1760_SetEECOPY(DevNum, NAI_FALSE);
   naiif_printf("\r\nDriving EECOPY input low.");

   naiif_printf("\r\nWait until READY output goes high for EEPROM copy completion...");
   do
   {
      naibrd_msDelay(1000);
      swResult = naibrd_1760_GetDeviceReady(DevNum, &ready);
   } while (!ready);

   naiif_printf("Copy Complete\r\n");

   swResult = naibrd_1553_Free(DevNum);
   return bQuit;
}

Help Bot

X