Bus Controller
Bus Controller
Application Examples
Devices Supported
HI-6130, HI-6131
HI-6132, HI-2130
HI-6137, HI-6138
HI-6140
May 2017
This application note can be used as a guide for developing Bus Controller software using
the Holt HI-613x family of MIL-STD-1553 Terminals. This is done through the development
of several application specific examples.
2 DEVICE INITIALIZATION
Before Bus Controller operation can begin, the BCENA input pin must be connected to logic
1 to allow BC operation. All Bus Controller operational registers must be properly
configured after a RESET is applied to the device and READY is high. The BC Instruction List
in RAM must be initialized to define message sequencing and conditional execution, and
finally the host must assert BCSTRT bit 13 in the Master Configuration Register 0x0000 to
initiate execution of Instruction List op codes.
Initial control of BC message sequencing involves the BC Instruction List Pointer in register
0x0034. Before BC execution begins, the instruction list starting address is copied from the
BC Instruction List Start Address Register, 0x0033. Once message sequencing is underway,
the BC Instruction List Pointer in register 0x0034 is updated by the BC control logic.
Table 2 shows a typical HI-613x Memory Map when using the Bus Controller. This memory
map will be similar for all Holt devices that support BC operation.
9 8 7 6 5 4 3 2 1 0
Figure 2 - BC Instruction List Op Code Format
Loopback Word Loopback Word High Time Tag Word High Time Tag Word
Block Status Word Block Status Word Block Status Word Block Status Word
Time Tag Word Time Tag Word Low Time Tag Word Time Tag Word
Time to Next Msg Time to Next Msg Time to Next Msg Time to Next Msg
Data Block Pointer Data Block Pointer Data Block Pointer Data Block Pointer
Bus Controller Configured for 16-Bit Time Base Bus Controller Configured for 32-Bit Time Base
Note that the pointer parameter in the BC instruction list referencing the first word of a
message’s control/status block (e.g. the BC Control Word) should contain an address value that
is modulo 8. If the message is an RT-to-RT transfer, the pointer parameter should contain an
address value that is modulo 16.
9 8 7 6 5 4 3 2 1 0
9 8 7 6 5 4 3 2 1 0
Figure 5 - Holt BC Block Status Word
The BC General Purpose Queue Pointer 0x0038 (see Section 11.8 of the HI-6130 Datasheet) is
initialized with the default starting address 0x00C0 after reset. The queue is re-locatable, so the
host may overwrite the default base address. Updated by the BC logic each time a data word is
pushed onto the queue, the pointer in register 0x0038 always points to the next storage
address in the queue to be written. The address pointer rolls over every 64th word written. If
the BCGPQ bit 13 is logic 1 in the BC Interrupt Enable Register, a BC interrupt is generated when
the General Purpose Queue Pointer rolls over from its ending address to its base address.
GPQ Word 63
GPQ Words 1 - 62
BC General Purpose
Queue Pointer GPQ Word 0
reg 0x0038
BC GP Queue
Increasing
in RAM
Memory
Address
HI-613x
Register
Space
INTERMESSAGE
GAP TIME
MINOR
FRAME
TIME
A minor frame will typically have a fixed duration such as 10ms, while a major frame will be
comprised of multiple minor frames. The periodicity of individual messages can then be
controlled by processing those messages in one or more minor frames allowing the user to
define highly deterministic bus traffic. The example bus list shown below illustrates one method
of implementing Major/Minor Frames using the Frame Timer to set the Minor Frame Time. The
main bus list makes calls to the minor frame subroutine and also to another subroutine that
waits until the Frame Timer counts down to zero. The Frame Timer can also be used to control
the Major Frame Time by using either the Time-to-Next Message or DLY Op Code to control the
Minor Frames. The below examples assume a BC Instruction List Start Address of 0x1B70.
Table 6- Subroutine NXTFRAME - Wait for Frame Timer to Expire and Reload
It is also possible to configure a scheme that differentiates between high priority and low
priority asynchronous messages. In this case, the high priority messages are sent out
immediately after the currently executing message, while low priority asynchronous messages
will be sent only if time allows at the end of the minor frame. If low priority messages are
expected, then enough time should be added to the minor frame time to allow one or more low
priority asynchronous messages to be sent as required.
The example shown in Table 9 is a modified version of the MINOR1 Frame shown previously. In
the example, the host processor will create a frame of one or more high priority asynchronous
messages and then set General Purpose Flag 3 (GP3) to have the BC process the asynchronous
messages.
Table 8 - Example of High Priority Asynchronous Message Insertion into MINOR1 Frame
Table 10 shows an example of the high priority message frame. This frame will execute two
high priority asynchronous messages and then clear GP3 before returning.
Table 9 - ASYNCH_HP subroutine will send one or more high priority asynchronous messages
The CAL opcode in the Minor Frame is replaced with a CAL (ALWAYS) and the address of the
asynchronous frame is provided when the asynchronous messages are desired to go out onto
the bus. The DSZ Opcode in the asynchronous frame attempts to decrement the value (initially set to 1)
stored at the first unused address in the Message Control/Status Block in RAM. If it is already zero the
DSZ Opcode will cause the next opcode is skipped. This ensures that the messages in the Asynchronous
Frame are only executed one time. The next time the host wishes to send the low priority asynchronous
frame, it must first reload the MCSB memory location to 0X0001. The first unused address in the MCSB
is at MCSB memory offset + 10. This method assumes that all asynchronous MCSB's are configured with
pointer parameters that are modulo 16. In this case, each MCSB is 16 words only 10 of which are used.
Asynchronous frame
In order to accomplish this, the JMP Op Code is used along with conditional branching. In this
case, the most significant bit (GPF4) is used as an enable bit to enter the conditional branching
instruction set. If GP4 is not set, then the code will return to the beginning of the minor frame.
If GP4 is set (e.g GP4_1 is true), then the BC will evaluate the remaining two bits to send the
appropriate message according to Table 12.
It should be noted that General Purpose Flags 0 and 1 are typically used for Fame Timer and
Message Timer comparisons and may not be available to the user. However, implementing an
expanded version of the scheme as described above would allow the remaining 6 General
Purpose Flags to be used which could support 32 possible outcomes with an enable bit or 64
possible outcomes if the enable bit is not used. The conditional messages shown in Table 12
could be also be conditional frames if CAL op codes are used rather than XEQ op codes.
Conditional
GP4 GPF3 GPF2 Message
1 1 1 4
1 1 0 3
1 0 1 2
1 0 0 1
Table 13 shows an example Minor Frame with three synchronous messages and up to 4
conditional messages which can be executed by setting a specific bit pattern in GPF(4:2). It
should be noted that in HI-613x memory each BC instruction list location is actually two 16 bit
words. One word for the op code and condition code and another 16-bit word for the
parameter. The actual memory address for the JMP op code will need to be adjusted
accordingly.
Memory Op
Location Code Condition Parameter/Address Comments
1 XEQ Always MSG1 Synchronous Message
2 XEQ Always MSG2 Synchronous Message
3 XEQ Always MSG3 Synchronous Message
4 JMP GPF4_1 +2 Jump Ahead 2 Memory Locations
5 JMP GPF4_0 -4 Jump Back to beginning of Frame
6 JMP GPF3_0 +2 Jump Ahead 2 Memory Locations
7 JMP GPF3_1 +3 Jump Ahead 3 Memory Locations
8 JMP GPF2_0 +4 Jump Ahead 4 Memory Locations
9 JMP GPF2_1 +6 Jump Ahead 6 Memory Locations
10 JMP GPF2_0 +8 Jump Ahead 8 Memory Locations
11 JMP GPF2_1 +10 Jump Ahead 10 Memory Locations
12 XEQ Always Conditional MSG1 Message 1 will execute if GPF(4:2) are 100
13 FLG Always Clear all flags
14 JMP Always -13 Jump Back to beginning of Frame
15 XEQ Always Conditional MSG2 Message 2 will execute if GPF(4:2) are 101
16 FLG Clear all flags
17 JMP Always -16 Jump Back to beginning of Frame
18 XEQ Always Conditional MSG3 Message 3 will execute if GPF(4:2) are 110
19 FLG Clear all flags
20 JMP Always -19 Jump Back to beginning of Frame
21 XEQ Always Conditional MSG4 Message 4 will execute if GPF(4:2) are 111
22 FLG Clear all flags
23 JMP Always -22 Jump Back to beginning of Frame
The host application software may require access to the latest version of a particular parameter
asynchronously to the process of the BC receiving the data from the RT. It will typically be
required to ensure data consistency. This means that for a data sample, the handshake
between the host and the Holt BC must ensure that the host does not read a mixture of new
data and previously received older data within a data block.
XQF
MCSB 0 @ 0xXX00
MCSB Pointer Control Word
Command Word
Data Block
Pointer Data Block 0
TTNM
TTW
BSW
LBW
RT Status
:
MCSB 1 @ 0xXX10
Control Word
Command Word
Data Block Data Block 1
Pointer
TTNM
TTW
BSW
LBW
RT Status
:
As shown in Figure 11, each time the message defined by the Control/Status block at 0xXX00 is
processed, the pointer parameter associated with the XQF op code may be defined to toggle its
bit 4. This will result in the pointer referencing the Control/Status block at location 0xXX10 the
next time that the message is processed.
In order to reduce the overall size of the BC instruction list and control/status block code size, it
is recommended to create a subroutine to process a particular message. The subroutine may
then be executed in multiple minor frames within a major BC frame. The BC instruction code
shown in Table 14 demonstrates the use of the XQF instruction to implement double buffering.
Address Op Parameter/
Mnemonic Code Condition Address Comments
Subroutine sta rt. Process message XQF Op Code. The
condi tion for the XEQ is GP3 = 0. The fi rs t time this line
is executed, the control/s ta tus block will be pointer to
MCSB0. Assuming that GP3 is TRUE, (i .e., auto-toggling
is ena bled), then pointer to MCSB0 will toggle to
MSG1XQF XQF GP3_0 MCSB1 or MCSBx <-MCSBx XOR 0x0010 = MCSB1
MCSBx
JMP BAD MESSAGE If BAD MESSAGE = TRUE, jump to "MSGERROR"
FAULT
If GP3_0 is true, auto-toggling is enabled. Return from
RTN GP3_0 Subroutine.
0X0000
If GP3_0 is false, auto-toggling is disabled. Set GP4, to
inform hos t tha t message was recei ved while the hos t
FLG Alwa ys was reading the Rx Message Block.
0X0010
RTN Alwa ys Subroutine Return
0x0000
Pus h value of BC i nstruction list on GPQ to inform hos t
MSGERROR PSM Alwa ys whi ch message failed.
START
Pus h messages Bl ock Sta tus Word on GPQ in indi ca te
PBS Alwa ys whi ch faul ts .
0X0000
IRQ Alwa ys Issue IRQ to hos t processor indi cating message failure.
Bi t Pa ttern
RTN Alwa ys Subroutine Return
0x0000
1. Set the general purpose flag GP3 by writing to the BC General Purpose Flag Register.
This temporarily disables the BC from auto-toggling control/status blocks and received
data blocks while the host is accessing the received data.
2. Read the current value of the control/status block pointer, which is stored at
address = MSG1XQF + 1.
4. To ensure that the most recently processed message was valid, read and verify the value
of the message’s Block Status Word.
5. If the message was valid, the host should then read the received data block.
6. After the host has read the data block, the status of GPF4 in the BC Condition Code
Register should be read to determine if a message was received, while the host was
reading the previous data block. If GPF4 is set indicating a message was received, then
the host should toggle the control/status block pointer by the equation:
In the case of BC-to-RT commands, the host processor has full control over the data blocks that
will be transmitted to the RT. Once a data block has been written, then the host can toggle the
data block pointer for the XEQ instruction. XEQ rather than XQF should be used for BC-to-RT
transfers since the host software is in control over the data block pointer toggling.
The HI-613x BC instructions can be used for combining message retry and bus switching
strategies. If the BC determines that a particular RT has failed, it can automatically switch the
message permanently from the original bus to the alternate bus saving BC bandwidth by
eliminating the need to retry messages on failed RT channels. The XQF instruction can be used
to implement an autonomous version of bus switching.
The example in Table 15 shows how to use the XQF Op Code to implement an autonomous bus
switching scheme.
Address Op Parameter/
Label Code Condition Address Comments
FLG
0x1000 Ini tialize by clea ring General Purpose Flag 4 (GPF4)
Execute the message, allowing one retry for a failed
message on the original bus . The “flip” condi tion is “BAD
MESSAGE.” If a “flip” occurs , the new MCSB poi nter will be:
MSG1 XQF BAD MESSAGE MCSBB = MCSBA XOR 0x0010
MCSBA
JMP GOOD MESSAGE If message was successful, jump to next message
NEXT
Condi tional jump to faul t subroutine if the GP4 general
purpose fla g bit was set. For this instruction, if GP4 is set,
this i ndi cates tha t the message had failed retries on both
JMP GP4_1 buses.
ERROR
FLG Alwa ys Set GP4 (uncondi tional)
0X0010
Retry the message using the new MCSB whi ch will try the
JMP Alwa ys message on the al terna te bus .
MSG1
Pus h value of BC i nstruction list on GPQ to inform hos t of
ERROR PSI Alwa ys messages failure on both buses
MSG1
Pus h messages Bl ock Sta tus Word on GPQ in indi ca te whi ch
PBS Alwa ys fa ults .
0X0000
Issue IRQ to hos t processor indi cating message failure on
IRQ Alwa ys both buses .
Bi t Pa ttern
NEXT Next Message
Figure 12 illustrates how to implement bulk data transfers using contiguous data blocks. The
diagram shows how to implement double buffering on a larger scale, by dividing a bulk data
structure into two sub-structures. These are designated as the “active” and “inactive. By “ping-
ponging” between two separate large contiguous blocks, the HI-613x Bus Controller can
transfer one block over the 1553 bus, while the host processor accesses the inactive data block.
An IRQ op code can be used to signal the host that one of the two blocks has been transferred.
Op Parameter/
Code Condition Address Comments
Execute a transmi t message to tell the RT to trans mit
XEQ Alwa ys a pa rameter designated by the label 0x123A.
MCSB
Pus h Immediate Value of 0x123A on the GPQ as the
PSI Alwa ys label identifier of the pa rameter.
0x123A
Pus h the recei ved da ta word on the GPQ. The
address of the data word within the message da ta
PSM Alwa ys block is used as the PSM Op codes Pa rameter.
Da ta Word
Address
Times tamp the logged pa rameter by pushing the
PTT Alwa ys Time Tag Value onto the GPQ
This capability described above can also be extended to support synchronizing the time tags of
multiple BCs by using the BCTRIG input signal. For the purpose of time synchronization, the
BCTRIG input from any number of Bus Controllers can be connected to the output of a common
time source.
Address Op Parameter
Label Code Condition / Address Comments
Wai t for a rising edge of the HI-613x BCTRIG
pin before continuing execution of the next op
WTG Alwa ys code in the BC ins truction lis t.
0x0000
Load the Time Tag Regis ter wi th 0x0000 to
LTT Alwa ys reset. Another time value could also be used.
0x0000
Execute Message. Synchroni ze (wi th da ta
word) mode code 17 command. This message
XEQ Alwa ys could also be sent as a broadcas t command.
MSG_MC17
NEXT Next Message
If the condition code evaluates as true, the WMI op code will write the parameter specified
immediate value to 0x0050 or the memory address specified by the last WMP instruction
performed. This allows the user to initialize the memory location with the value of 'N'.
For the DSZ op code, if the condition code evaluates true, the value stored at the memory
address specified by the parameter word is decremented. If the new value is non-zero, the next
instruction is executed. If the decremented value is zero, the next instruction is skipped.
Address Op Parameter/
Label Code Condition Address Comments
Set WMI pointer wi th the immedia te value of
0x0A00. Defaul t WMI pointer value is 0x0050
WMP Alwa ys and i t mus t be set to a value > 0x0049.
0x0A00
Set the number of i tera tions to N, in this case
WMI Alwa ys 0x000A so tha t the loop will execute 10 times .
0x000A
CAL Alwa ys Call subroutine LOOP
LOOP
NEXT Next Message