Low Level Protocol Implementation 

 

Protocol description showing our ability for programming at the lowest level.  

Go to Home Page

SP Commands

Introduction:

The way of communication with the DSP (TMS320F2812) is through an 8K dual port chip mapped to address 0xC0000. Internal mapping goes as follows:

 

Location                                              Offset                          Content Symbol

DP_IM_ALIVE_TOGGLE                  0x0000                                    ImAlive

 

DP_CMD_ID                                      0x0001                                    cmdId

DP_CMD_DATA                                0x0002                                    cmdData[]

 

DP_REPLY_ID                                   0x1001                                    replyId

DP_REPLY_DATA                             0x1002                                    replyData[]

(See Intruder protocol)

DP_READING                                    0x1F38

DP_QTY                                             0x1F39

DP_INTRUDER                                  0x1F3B

 

Every 10 ms, the command poll service (cmdPollSrv)  software interrupt is activated by a DSP timer. ImAlive toggles on every entry to the service routine. By monitoring this location can it can be known if the DSP is active.

 

The service will check for the content of location DP_CMD_ID,  cmdId, if different than 0, then a command has been received.  Commands may have associated data or even subcommands.  Data associated to a command must be loaded as an array (cmdData[]) starting at location DP_CMD_DATA, before the command, cmdIdx, is entered into location DP_CMD_ID.

 

When the DSP is done executing a command and is ready for the next, it writes a 0 to cmdIdx in location DP_CMD_ID.

 

Some commands may request data.  If so, data will be returned starting as array replyData[] starting from in location DP_REPLY_DATA.  In DP_REPLY_ID, the DSP software will return the command number incase everything went OK, in case of error the command number plus 0x1000 will be returned.

 

The DSP will only reply when spoken to, so DP_REPLY_ID need not be monitored.

 

CmdID 0x1, Master Interrupt Enable/Disable

 

There are two interrupts being serviced by the DSP, one (Int1) is triggered by an external 250 Hz clock and the second by 1 KHz pulses from an internal clock.

 

Int1 tasks:

  1. Updates timers A, B, C, D and the system tick.
  2. Read the 8 channels of the analog to digital converter
  3. Reads the 4 channels of the Synchro.
  4. Updates counters logical channel queues and feeds the physical queues
  5. Transmits the head contents of every physical channels if it is available for transmission

 

Int2 tasks

  1. Check al receiver channels status and read any info available
  2. read the label an store it in the hash buffer.

 

If the Master interrupt is disabled only task 1 of Int1 is executed.

 

Syntax:

cmdId = 1

cmdData[0] = 0/1  for enabled/disabled

CmdId 0x2, 0x3, 0x4, 0x5 word and byte IO

0x2 and 0x3 are for word input and output respectively, while 0x4 and 0x5 are same for bytes.

 

For cmdId = 0x2 and 0x4 the syntax is:

cmdData[0] = IO offset address

cmdData[1] = word or byte value to output

 

For cmdId = 0x3 and 0x4 the syntax is:

cmdData[0] = IO offset address

the reply syntax is:

replyID = 0x3 or 0x4

replyData[0] = word or byte value read

CmdId 0x6   Reset Timer Registers

The Bit 3 application uses 4 independently resettable timers and a system tick, which are incremented every 4 milliseconds.  It takes one parameter in cmdData[0], if is 0 or greater than 4, all timers and the system tick are reset. If 1, 2, 3 or 4, timers A, B, C or D are reset respectively..

 

CmdId 0x7         Read Timers

Return A, B, C, D timers and the system tick an array of 5 longs,, starting at DP_REPLY_DATA.

 

Reply syntax:

replyID = 0x7

replyData[0]     = Timer A

replyData[1]     = Timer B

replyData[2]     = Timer C

replyData[3]     = Timer D

replyData[4]     = System Tick

 

 

CmdID 0x8  Measure Interrupt Frequency

Returns frequency in replyData[0].

CmdId 0x9, 0xA, 0xB and 0xC  AD converter  settings

 

cmdData[0]  holds the value to be set.

 

0x9      0/1       Enables/Disables periodic reading of all eight channels, one every 4 ms.

0xA      0/1       Set reading mode to Unipolar/Bipolar.

0xB      0/1       Sets the range to 20v/10v

0xC      W        Sets code base for the AD MUX, nibble selects the channel to be read.

 

These commands have no reply.

 

CmdId 0xD Read Synchro Data

The 4 Synchro registers are read one at a time every 4 ms and saved to a memory array. This commands returns these readings starting at DP_REPLY_DATA.

 

replyId             = 0xD

replyData[0]     = Synchro data channel 0

replyData[1]     = Synchro data channel 1

replyData[2]     = Synchro data channel 2

replyData[3]     = Synchro data channel 3

 

CmdId 0xC Read Analog Data

The periodic readings of the 8 AD converter channels are returned as an array starting at DP_REPLY_DATA.

 

replyId             = 0xC

replyData[0]     = AD converter data channel 0

replyData[1]     = AD converter data channel 1

replyData[2]     = AD converter data channel 2

replyData[3]     = AD converter data channel 3

replyData[4]     = AD converter data channel 4

replyData[5]     = AD converter data channel 5

replyData[6]     = AD converter data channel 6

replyData[7]     = AD converter data channel 7

 

CmdId 0xF Read the RMS from a Specified channel

Returns the Root Mean Square the voltage on a channel.  There are two modes: signal and noise.

 

Syntax:

cmdData[0] = channel from 0 to 7

cmdData[1] = mode

 

The algorithm is based on the Root Mean Squares definition:

Vrms = Ö (SN(Vn-Vavg)2/N)

Where Vavg is the average voltage and N the number of readings.

 

Signal Mode:

Here the signal is known to be approximately sinusoidal. To improve accuracy, the samples will only be valid for collecting after a first zero crossing from – to +.  Valid data must have, not only a value greater than a threshold, but the increment from the previous reading must be also greater than a threshold. This is necessary because the signal to be measured is intermittent and the off parts must be disregarded.

 

The ADC will be sampling every 68 ms for 150 ms (2200 samples). The last zero crossing will be registered and uses as N in the above formula, so that only full cycles will contribute to the calculations

 

Noise Mode:

In this mode zero crossing is meaningless and there’s no off time. Also there is a 2 Hz pulsed interference from the transmitter included in this noise. To avoid missing these pulses, samples must be collected for at least a ½ second..

 

Sample rate in noise mode will be 272 ms, so 2200 samples will cover more than half a second. The ADC will be reading from a sample and hold circuit driven at 200Hz (fs).

 

If we assume an audio bandwidth (Bw) from 200 to ~8KHz. and consider a fairly constant power density (pd) within that band we can make an estimate of the actual noise power from our measured RMS value.

 

A zero order sample and hold frequency (fs) of 200Hz, applies a filter with a frequency response described by: (ref (http://www.dspguide.com/ch3/3.htm))

 

F(f) = sin((p/fs)f)/ (p/fs) f = sinc((p/fs) f)           

 

Rendering a power spectrum

 

W(f) = pd * sin2((p/fs)f)/ ((p/fs) f)2

 

Integration from 200 Hz to 8 KHz yield the power of the sampled signal, that for this case, is as good as doing it from 0 to infinity. But, since the integral 0 to infinity of sin2(x)/x2 is known to converge to p/2:

 

Wrms = pd * fs/2      Or     Pd = 2 * Wrms/fs

 

The real noise power (Wnoise) in the band is Bw*pd, so :

 

Wnoise = 2 * Bw * Wrms/ fs    ~   80 * Wrms

 

So the real noise power should be 80 times that of the measured RMS value. For example is the measured value is 6 mv in 8 ohms, or  4.5  mW, the  real power would be 360 mW. In this case the signal to noise ratio with a 1W output would be of 34 dB..

 

Reply Syntax:

replyId                         = 0xF

*DP_REPLY_DATA = pointer to a double holding the RMS value.

 

CmdId 0x10 Upload for 429 transmission

Uploads the queue of a logical transmission channel. 

 

Syntax:

cmdData[0]                  =  logical channel

cmdData[1]                  =  queue tail (label count)

 

cmdData[2]                  =  arinc dword[0]

·         

·         

·         

 

cmdData[2+19]            = arinc_dord[18]

 

cmdData[2 + 20]          = period[0]

·         

·         

·         

 

cmdData[2 + 20 + 19] = period[18]

CmdId 0x11 and 0x13 Set Flags

Set the xmit/recv flag values res[ectively.

 

Syntax:

CmdId             = 0x11 or 0x13 for xmit/recv flags.

CmdData[0]     = xmit/recv flag values.

CmdId 0x12 and 0x14 Read Flags

These commands read the status of transmit and receive flags respectively.

 

Return Syntax:

replyId[0]         = 0x12 or 0x1 for xmit/recv flags.

replyData[0]     = xmit/recv flag values.

 

Commands have no parameters.

CmdId 0x15 and 0x16 Set and Read Speed Array

Each of the 19 logical channels is set to go in high or low speed. The array is set using command 0x15 with the following syntax:

 

Syntax

cmdId              = 0x15

cmdData[0]      = 0/1 low/high speed for channel 0.

·         

·         

·         

cmdData[18]    = 0/1 low/high speed for channel 18.

 

For reading the current speed array:

 

Syntax:

cmdId  =          0x16

no parameters

 

Return Syntax:

replyId[0]         =

replyData[0]     = 0/1 low/high speed for channel 0.

·         

·         

·         

replyData[18]   = 0/1 low/high speed for channel 18.

CmdId 0x17 Initialization Commands

This command has five subcommands for performing this number of different initialization routines.

Syntax:

CmdId             = 0x17

cmdData[0]      = Subcommand 1 – 5

cmdData[1]      = Receiver channel number for subcommand 3

 

Subcommand 1            initialize  xmit and recv devicess

Subcommand 2            Reset logical queues

Subcommand 3            Flush receiver channel

Subcommand 4            Flush all receiver channels

Subcommand 5            Reset Multiplexers

CmdId 0x18 Set Receiver Speed

Set the speed for a specified receiver channel.

 

Syntax:

CmdId             = 0x18

cmdData[0]      = Channel number 0 – 5

cmdData[1]      = 0/1 low/high speed

CmdId 0x20 Download 429 transmission

Downloads the queue from a logical transmission channel. 

 

Syntax:

cmdData[0]                  =  logical channel

 

Return Syntax:

replyId                         = 0x20

replyData[0]                 =  queue tail (label count)

 

replyData[1]                 =  arinc dword[0]

·         

·         

·         

 

replyData[1+18]           = arinc_dword[18]

 

 

replyData[1 + 19]         = period[0]

·         

·         

·         

 

replyData[1 + 19 + 18] = period[18]

CmdId 0x21 Read Received Data

Returns either the info of 19 most recent labels received for a single channel or for all the channels.  The info includes the measured period and system tick value as a time stamp.

 

Syntax:

CmdId             = 0x21

CmdData[0]     = Channel

 

Return Syntax for a valid channel (0-5):

replyId             = 0x21

replyData[]       block for specified channel starts here

 

Return Syntax for and invalid channel >5 (returns all channel blocks):

replyId             = 0x21

replyData[0]     =  total word count

replyData[1]                                         block for channel 0 starts here

replyData[p=(1+ blkSize(0))]               block for channel 1 starts here

replyData[p=(p+ blkSize(1))]               block for channel 2 starts here

replyData[p=(p+ blkSize(2))]               block for channel 3 starts here

replyData[p=(p+ blkSize(3))]               block for channel 4 starts here

replyData[p=(p+ blkSize(4))]               block for channel 5 starts here

 

Structure of a Block for single channel n

replyData[p]                                         =  labelCount

replyData[p+1]                         =  labelArrayChn[0]

·         

·         

·         

replyData[p+1 + labelCount]                = Arinc_dword_Chn[0]

·         

·         

·         

replyData[p+1 +3*labelCount] = periodChn[0]

·         

·         

·         

replyData[p+1 +4*labelCount]             = tickChn[0]

·         

·         

·           { blkSize for Ch n}

replyData[p+(1 +6*labelCount)]         = tickChn[labelCount-1]    (End of block for Ch n)

CmdId 0x22 Return Xmit and Recv Counters

Every entry to a transmit or receive routine increments a counter. This counter indicate activity to the host program and this command return the current value of such counters. The command has no parameters.

 

Reply Syntax:

ReplyId                                    = 0x22

ReplyData[0]                            = xmit counter

ReplyData[1]                            = recv counter

CmdId 0x23 Transmit Immediate

Transmits an Arinc Double Word on a specified logical channel, as soon as its associated physical channel is ready. CmdId = 0 will only be returned when transmission is done.

 

Syntax:

CmdId             = 0x21

cmdData[0]      = Logical channel number 0 – 18

cmdData[1]      = ARINC lo-word

cmdData[2]      = ARINC hi-word

CmdId 0x25 &  0x24  Collect and Render Ch 0 Stream Data

Five streams may be received on Channel 0:

 

0.   Maintenance

  1. EEPROM
  2. Interrogation
  3. WS
  4. ATE

 

Command 0x25 turns on the collection and sets the data count of one of the 5 streams. On streams 1 to 4, which consist of a single label series, data is collected until it reaches a specified count and then it is turned off.

 

Maintenance is different, it may have several labels.  So, to  specify the stream, it uses an SOT (Start Of Text the 0x020000FC) and an EOT (End Of Text 0x040000FC) DWORD.  Also, in this case, the count may not reach the one specified.

 

Syntax:

CmdId             = 0x25

cmdData[1]      =  Stream Type (0-4)

cmdData[2]      =  data count.(cnt)

 

During collection the HOST can poll the progress with CmdId 0x29. 

 

To deliver the collected data to the host, command 0x24 must be invoked. If CmdId 0x24 is invoked before collection is finished, replyData[0] will return false (0). Once finished, it will return the first element of the data array.

 

Syntax:

CmdId             = 0x24

cmdData[1]      =  data chunk size.(cnt)

 

The difference between reading, for instance, EEPROM to reading Maintenance data, is size. While EEPROM data array can fit entirely into the dual port, maintenance data, being potentially larger than 0xfff words, can not. So it must be read by iterating cmdId 0x24.  This command allows specifying the maintenance data chunk you want to read, it returns the actual chunk size, which could less than the one requested if at the end of the data array.  A Chunk size of 0, will be interpreted as  a request for all collected data.

 

Return Syntax:

replyId                         = 0x24

replyData[0]                 =  0 if collection unfinished/Data dword[0] if collection is done

·         

·         

·         

 

replyData[cnt]  = Data dword[cnt-1]

 

If cmdId 0x24 is issued beyond the last chunk of data, without restarting a new data collection, it will return false, the array is returned only once. 

CmdId 0x26 Store EEPROM Data for Transmission

EEPROM data can be transmitted either by using cmdId 0x23 (Transmit immediate) or by this one.  The EEPROM dword array supplied will be transmitted at 4 ms interval.

Syntax:

CmdId             = 0x26

cmdData[0]      =  EEPROM data count.(cnt)

cmdData[1]      =  EEPROM dword[0]

·         

·         

·         

 

rcmdData[cnt]  = EEPROM dword[cnt-1]

CmdId 0x29 Stream collection progress indicator

Since the streaming of data may not be immediate in human terms, a progress indicator becomes necessary. This command will return the number of Channel 0 stream dwords that have been received. It has no parameters

 

Return Syntax:

replyId                         = 0x29

replyData[0]                 =  Maintenance dword count.

CmdId 0x2A, 0x2B & 0x2C TCAS Data Processor Loader

 

CmdID 0x2A initializes the loader mode in the DSP and sends the RTS word to TCAS, the DSP wait for the CTS word from TCAS for up to 100 ms, after which it will return 0x00000000 in replyData[0] and replyData[1], the host will repeat the command. If a CTS with a block count different than zero is received within one of the 100 ms periods, the DSP will be return it as a long in replayData.

 

Syntax:

CmdId             = 0x2A

cmdData[0]      =  RTS Least Significant word

cmdData[1]      =  RTS Most significant word

 

Return Syntax:

replyId                         = 0x2A

replyData[0]                 =  valid CTS ARINC word or 0 if timeout.(100 ms)

 

CmdID 0x2B sends a single block. The RTS can request sending up to 5 blocks. A block consists of an initial label (220) called DF (Data Follows), which bears the information of the Intermediate Words (IW) count and then the Final Word (DF). The labels in the block will be transmitted at a 2 ms interval. The DSP will repeated every the FW 60 ms until a valid CTS is received.

 

Syntax:

CmdId             = 0x2B

cmdData[0]      =  DF

cmdData[2]      = IW[0]

·         

·         

·         

cmdData[2n+2]  = IW[n]

cmdData[2n+4]  = FW

 

Return Syntax:

replyId                         = 0x2A

replyData[0]                 =  valid CTS ARINC word or 0 if timeout (10 secs).

 

CmdID 0x2C will notify the DSP that the load task is over and that it must return to normal operation.  This command has no reply.

 

Syntax:

CmdId             = 0x2C

Intruder Protocol

Receiver Ch 5 is constantly being polled for intruder data. SOT of an intruder data block is 0x120000EF and the EOT is 0x030000EF.  Between this two ARINC words, the data for up to 32 intruders may be sent. There are 3 labels (Octal 130, 131 and 132) for each intruder within the block. The maximum size of the block being 196 words:

 

196  =  (32 intruders x 3dwords + SOT + EOT) *2 words

 

This information is double buffered. While being collected, it is stored in a 196 word RAM memory buffer dynamically allocated upon object construction. Upon receiving the SOT, this information is transferred to a second buffer, also of 196 words, at the high end (0x1F3B) of the dual port memory, where it can be directly read by the host without the latency of a command. Th DSP software will write at location 0x1F39, the number of ARINC DWORD’ s (including SOT and EOT).

 

To avoid writing in the buffer while it is being read, the host will set location 0x1F38 to 1, the DSP software will hold while this location is different than zero. 

 

Once the host has read the buffer, it will set location 0x1F39 to zero, then it will poll this location until it the DSP writes new info onto it. This way, it will known when there’s something to be read. The DSP software will transfer the data first and write the ARINC DWORD count for last, making sure that when the host sees a value there different than zero, the data is ready to be read.

 

Go to Home Page