Notes on the PC/DSP interface for the DSP-10 transceiver. Version 2.00 Bob Larkin W7PUA 10 Feb 2001 The author can be contacted by email at boblark@proaxis.com. Alternatively contact the author at Robert S. (Bob) Larkin 2982 N. W. Acacia Place Corvallis, OR 97330 USA For more details on the background or use of the program, pay a visit to http://www.proaxis.com/~boblark/dsp10.htm and, This document describes the interface between the DSP program running in the EZ-KIT Lite and the control program. This is valid for version 2.00 of the DSP program UHF3.EXE. Control is through the 9600 baud serial port. This interface has been revised considerably since version 1.6 of the DSP-10 software. Further revisions will make every possible effort to leave the commands, that are documented at this time, intact. Unused bits in control bytes may be added, but the existing commands and bit definitions should not change. Additional commands can be expected to be added. In order to be forward compatible with the existing Analog Devices Monitor commands, the following commands should not be used (in future additions): '$', 'O', 'U', 'D' or 'G', all of which are prefixed by a '$' escape character. See the EZ-Kit manual for further details of the monitor commands. The idea is to allow the DSP-10 to intercept EZ-Kit commands and pass them on to the monitor. ---------------------- Misc Notes -------------------------------- Described below is a table of pointers, located in program memory for the DSP. To allow finding this table, a pointer to it is located at location 1 in program memory. This is the second memory location in the Interrupt Vector Table. The first location in program memory is the jump instruction that is executed at a "Go 0". The first instructions in program memory are: .module/ram/abs=0 UHF3; jump start; { PM location 0, reset vector } .var/pm/ram/abs=1 tbl; .init tbl: ^ptr_table; { PM location 1, address of pointer table } where ^ptr_table translates to "address of ptr_table." The Pointer Table makes important tables & variables available to PC. There are 38 24-bit entries. The DSP program listings give the best definitions of the various labels, but for many, the 8 audio filters fir3_coefsi where i can be 1 to 8 are the most important. The order for the pointer table, shown below, is taken from the data initialization and the symbol ^xx reads as "address of xx." The last entry is a validity check when loading the table to the PC. .var/pm ptr_table[38]; .init ptr_table: ^ham_win, ^bh4_win, ^tukey_win, ^fir1_coefs, ^fir1a_coefs, ^wfir2_coefs, ^fir2_coefs, ^fir3_coefs0, ^fir3_coefs1, ^fir3_coefs2, ^fir3_coefs3, ^fir3_coefs4, ^fir3_coefs5, ^fir3_coefs6, ^fir3_coefs7, ^fir4_coefs, ^fir5_coefs, ^fir6_coefs, ^fir7_coefs, ^fir8_coefs, 0, 0, ^fir1200_coefs, ^fir2400_coefs, ^hilbert1_coeff, ^hilbert3_coeff, 0, 0, 0, 0, ^xmit_status_buf, ^cmd_buf, ^esc_a, 0, ^buf_len_table, 0, ^filter_id, 0X123456; ---------- Triggered Spectral Data Collection Timing -------- There are three triggered spectral data collection timings illustrated by the following timing diagrams. The trigger for these data collection periods can come from either software or an input low-to-high logic pulse to the DSP. The notation of |--i--| corresponds to the ith data collection time period. Triggered measurement for 9600 Hz sample rate, 1.92 second collection. Overlapping 0.10667 second data periods: Trig |--1--|--3--|--5--| Stop and 2 more |--2--|--4--|--6--| identical sequences. The 1.92 seconds of data collection is divided into thirds. Data is sent as three blocks that can optionally be combined in the PC. Each set of three requires a single software or hardware trigger. Since the length of the data collection is short of 2 seconds it is possible to trigger these measurements every 2 seconds. Triggered measurement for 4800 Hz sample rate, 1.92 second collection. Overlapping 0.21333 second data periods: Trig |--1--|--3--|--5--|--7--|--9--|-11--|-13--|-15--|-17--| Stop |--2--|--4--|--6--|--8--|-10--|-12--|-14--|-16--| Unlike the 9600 triggered measurements this does not divide into thirds and is sent as a block after 1.92 seconds. Triggered measurement for 2400 Hz sample rate, 1.92 second collection. Overlapping 0.41667 second data periods: Trig |----1----|----3----|----5----|----7----| Stop |----2----|----4----|----6----|----8----| Again, this does not divide into thirds and is sent as a block after 1.92 seconds. -------------------- PC to DSP Commands ----------------------- All commands are six bytes. The first character is always an escape byte. The second byte identifies the command. The remaining 4 data bytes vary according to the command. They are explained below. Starting with revision 2, the 'ESC' escape character is '$' or 24 hex. The term "nu" means that the byte is not used. To help with debugging, the unused bytes from UHFA.EXE are usually filled with an integer corresponding to the byte position 1, 2, 3 or 4. Command 1: ESC 1 adrl adrh datal datah Places a 16 bit word 256*datah+datal into data memory at location 256*adrh+adrl. The address should be within the 14 bit address space of the unexpanded 2181 processor. Command 2: ESC 2 adrl adrh datam datah Places 256*datah+datam into the high order 16 bits of program memory at location 256*adrh+adrl. This is the normal data alignment for placing 16 bit data into 24 bit program memory. The address should be within the 14 bit address space of the unexpanded 2181 processor. The low-order 8 bits of the PM location are preserved. Command 3: ESC 3 adrl adrh datal nu Places datal into program memory at location 256*adrh+adrl. The address should be within the 14 bit address space of the unexpanded 2181 processor. The last byte is not used and can have any value. The higher order 16 bits of the PM location are preserved. Command 4: ESC 4 adrl adrh tag nu Uploading Data Memory from the DSP to the PC. Bytes 1 & 2 have the address (256*adrh+adrl) and byte 3 has a tag to let the PC identify which data has arrived. This tag should be changed by the PC program for each new word that is requested. The 16 bit result is returned to the PC with the low and high bytes in status bytes 7 and 8. The tag is returned in status byte 13. See the Command 9 for more details. Command 5: ESC 5 adrl adrh tag nu Uploading Program Memory from the DSP to the PC. Bytes 1 & 2 have the address and 3 has a tag to let the PC identify which data has arrived. This tag should be changed by the PC program for each new word that is requested. The 24 bit result is returned to the PC with the low, middle and high bytes in status bytes 18, 7 and 8. The tag is returned in status byte 13. See the Command 9 for more details. Command 7: ESC 7 data nu dphil dphih This is a specialized instruction that is a combination of the 3rd LO (9-21 kHz) frequency and the enable line for the 126 MHz synthesizer. By placing these in the same instruction it is possible to shift the synthesizer frequencies at about the same time. Otherwise, when tuning across a frequency band there is a time when the frequency is very wrong. This occurs when the 126 MHz synthesixzer is stepping up by 5 kHz and the 3rd LO is stepping down by about 5 KHz. The bit 0 of byte "data" is transferred to hardware line PF7 when this command is received. This enables a previously loaded synthesizer (amd shift register) data set as sent by command 8. The 16 bit phase increment for the 3rd LO is in bytes dphil and dphih. The LO frequency is: freq=24000(256*dphih + dphil)/32768 Hz. Command 8: ESC 8 datal datah nu nu Enables the shifting of 16 bits of data to the shift registers and U104. The 16 bit word is 256*datah+datal. This can be shifted out in 16*3*104=4992 uSec which is less than the time required to receive the next command (6*1042=6252 uSec), so one need not be concerned about overwriting this command. Command 9: ESC 9 size shift offsetl offseth This command (was 'D') sets the format for the spectral log-power data being sent to the PC. It can be 8 bit with a resolution of 0.3125 dB or 16 bit at a resolution of 0.001221 dB. In order to not slow the stream excessively, only the first 256 ppowers are sent in 16-bit form, whereas in 8-bit form all 512 log-power data are sent. For 8-bit data it is necessary to specify the 80 dB range to be sent (data outside that range takes either a value of either 0 or 255, as appropriate). The 80-dB range is specified first by a power of 2 with "shift" and then as an offset in by 256*offseth+offsetl where the least significant bit is 0.001221 dB. In addition, there is an option of sending no spectral data at all. This is used with the 4 and 5 commands above. The streams of data are prefixed by either 'A' or 'B' depending on whether spectral data is sent or not. The command 9 format is: size: Bit 0 0=8 bit data, 512 bytes 1=16 bit data, 256 words Bit 1 0=Send spectral data, 'A' stream 1=Send only status data, 'B' stream shift: Shift value, power of 2 offsetl, offseth: Offset applied to 8 bit log data. When size Bit 1 is set, only status bytes are being sent, normally used with the 4 or 5 commands for sending dm or pm data to the PC. No data samples are taken, no FFT's occur. In order to not send the 512 bytes of data plus check sum, the following commands should be sent from the PC: 9 cmd Byte 1, bit 1 =1: Suppress FFT data transmission 'F' Bytes 1&2 bit 9=1, bit 11=0: Software trigger 'F' Bytes 1&2 bit 14=1: Suppress FFT data collection 4 or 5: This command sets the software trigger. The 4 or 5 can be repeated any number of times to get dm or pm. To return to ordinary FFT: 9 cmd Byte 1, bit 1 =0: Anable FFT data transmission 'F' Bytes 1&2 bits 9&11 set per data mode needs. 'F' Bytes 1&2 bit 14=0: Enable FFT data collection Note that strange results will occur if 9 command is not used to suppress spectral data transmission, since the data is not being updated, but old data is being sent to the PC. Command 10: ESC 10 gainl gainh shift nu This command (was 'G') sets the audio gain. It is a combimation of a binary shift and a multiplier. The total voltage gain is (256*gainh+gainl)*2^shift where shift can be either + or -. Command 65 ('A'): ESC 65 filt lms nu nu Controls the use of both the audio and LMS filters. Bytes are: filt: 0=Off 1=FIR audio filter On lms: 0=LMS Auto Notch 1=Off 2=LMS DeNoise Command 66 ('B'): ESC 66 nfilt fshift nu nu This command selects the audio FIR filter filter coefficients. The FIR coefficients for narrow-band filters can be allowed to have some gain to improve their out-of-band accuracy. This gain is removed by -nshift after the FIR computation. The 40 bit accumulator prevents overload, but for very narrow filters there can be lack of resolution on noise, due to the spectral exclusion of the noise. Less nshift will reduce that effect. The parameters for this command are: nfilt Audio filter number, 0 to 7. fshift Gain 1 to 128, specified by 0 to 7 where A=2^fshift Command 67 ('C'): ESC 67 dnbeta dndecay notchl notchh This command sets the beta 'adaptation gain' and decay for the denoise and auto notch, and also the delay line length. The adaptation gain, beta is sent square root compressed. This allows one byte to be adequate. The bytes are: dnbeta DeNoise beta is dnbeta^2-1 dndecay DeNoise discard of old data is 32735-2*dndecay, corresponding to a range of (32735, 32238) or 1.15 equivalent decimal of (0.999, 0.984). The LS bit of dndecay is masked off and is the delay line length. Bit 0=0 is a length of 31 and 1 is a length of 61. notch The beta adaptation gain for the autonotch given by 256*notchh+notchl Command 69 ('E'): ESC 69 delayl delayh nu nu This command sets the delay of the right channel for time diversity binaural. 256*delayh+delayl is the delay (1,2048) where the units are 1/48000 sec = 20.833 usec. The delay is set to 1 for no delay. Command 70 ('F'): ESC 70 paraml paramh ttag nu This command sets the various parameters of the FFT for spectral data collection. The 256*paramh+paraml bit definitions: 0 1.2 kHz input, 2.4 kHz sample rate 1 2.4 kHz input, 4.8 kHz sample rate 2 4.8 kHz input, 9.6 kHz sample rate 3 48 kHz sample rate (future) 4 256 point (future) 5 512 point (future) 6 1024 point 7 0=2.8 kHz I-Q, 1=4 kHz; I-F filters 8 nu 9 Triggered 0=Free run, 1=trig per bits 10 & 11 10 Software trigger, start on 1 (reset by DSP collection fcn ) 11 Trig source 0=bit 10, 1=hardware PF0 12 0=3 data sets per 2 sec, 1=1 data set per 2 sec 13 0=2.8 kHz Interp 1=4 kHz 14 0=normal, 1=no FFT, used for commands such as '4' and '5' 15 nu ttag meanings 0, 1 0 2-7 Time tag, multiple of 2 seconds starting at top of minute Command 72 ('H'): ESC 72 dphl dphh levl levh This command sets the sidetone frequency and amplitude that is available during key down in transmit. The sidetone frequency is 24000*(256dphh+dphl)/32768 Hz. The amplitude is scaled from maximum DAC output by (256*levh+levl)/32768. Command 74 ('J'): ESC 74 insel outsteer sysctrl nu This command controls several general system parameters. outsteer: 0=Rcvr audio to Left and Right DAC's, Transmit I-F to left DAC. 1=Rcvr audio to left DAC, Transmit signal to right DAC sysctrl: Bit 0=0 Monitor commands are ignored Bit 0=1 Monitor commands will be intercepted by the DSP. } Command 77 ('M'): ESC 77 mode sb mikel mikeh This command controls the mode (cw, ssb, fm) and the sideband selection (usb, lsb, i-q binaural) and the mike gain. The i-q binaural should be considered experimental and may underfo future change, so contact W7PUA if you are using that mode to get the current status. The mike gain is 4*(256*mikeh+mikel). The factor of 4 compensates for some situations where there was a lack of amplification in the mike preamp. It also means that one can overload the 16-bit word in the DSP if too much input is applied. The first two bytes are: mode 0=single sideband 1=CW 2=FM sb 0=LSB at the 9 to 21 kHz I-F 1=USB at the 9 to 21 kHz I-F 2=I-Q binaural per KK7B Command 82 ('R'): ESC 82 reset nu nu nu DSP reset functions are available here, but should be used with care since all processing stops during there execution and the PC needs to use a blind delay to wait for this to complete. All processing will have a brief interruption. The time involved has not yet been measured. Bit 5: Immediate Reset is executed on receipt. All others are not executed if the DSP is servicing an interrupt, but are delayed until the background process begins again. The byte "reset' is used bit-by-bit: Bit 0: call local_init - General process initialization Bit 1: call init_util - CODEC, UART and Filters Bit 2: call LMS_init - AutoNotch and DeNoise Bit 3: call prog19mhz - The 19.680 MHz synthesizer Bit 4: jump fresh_start - Everything, from background process Bit 5: immediate fresh_start, breaks interrupt process Command 83 ('S'): ESC 83 sqll sqlh nu nu Squelch set for FM, value 256*sqlh+sqll Command 84 ('T'): ESC 84 ctrl nu tpwrl tpwrh Transmit/Receive Control and transmit power. This only places the DSP into transmit or receive. It does not control the hardware which should be done by the shift register contols (see commands 8 and 7). The transmit power is a multiplier between the waveform generation and the DAC output and is set by 256*tprh+tprl. T/R control is by the first byte: Bit 0 = 0 for dsp receive = 1 for dsp transmit Bit 1 = 0 if no transmit status is sent = 1 if transmit status is sent Bit 4 = 0 for cw key up = 1 for key down Command 86 ('V'): ESC 86 nu nu agcl agch Sets the AGC time constant. A special case is a value 0 which turns off AGC. The delay constant is 256*agch+agcl Command 87 ('W'): ESC 87 win iffil nu nu Selects the FFT windowing function and the I-F filter bandwidth. Windowing is set by win: 0 = No window 1 = Tukey 25 percent 2 = Hamming 3 = Blackman-harris 92 dB The I-F bandwidth is set by iffil 0 = 2.8 kHz 1 = 4 kHz ------------------------- Receive status -------------------------- The status bytes sent to the PC during receieeve are defined by the following program snippet. Note that the initial values set by ax0 are generally altered during program operation: ax0=ESC_CH; dm(esc_a) =ax0; { Initialize escape sequence } ax0=0x41; dm(esc_a+1)=ax0; ax0=0x20; dm(status_buf+0)=ax0; { Version number } ax0=00; dm(status_buf+1)=ax0; { UART Receive errors } ax0=32; dm(status_buf+2)=ax0; { Last cmd received } ax0=32; dm(status_buf+3)=ax0; { AGC Gain, low } ax0=32; dm(status_buf+4)=ax0; { AGC Gain, high } ax0=32; dm(status_buf+5)=ax0; { Ave power, low, FM only } ax0=32; dm(status_buf+6)=ax0; { Ave power, high, FM only } ar=^ptr_table; dm(status_buf+7)=ar; { General data to PC - see +13, low } sr=lshift ar by -8 (hi); dm(status_buf+8)=sr1; { General data to PC, high } { Low 4 bits of +13 are index. If 0 then bytes +7 and +8 are the address of the pointer table (default). Else data requested is returned in bytes +7 and +8 unless it is from PM in which case the low 8 bits are in +18 } ax0=32; dm(status_buf+9)=ax0; { A/D biggest, low } ax0=32; dm(status_buf+10)=ax0; { A/D biggest, high } ax0=32; dm(status_buf+11)=ax0; { D/A biggest, low } ax0=32; dm(status_buf+12)=ax0; { D/A biggest, high } ax0=32; dm(status_buf+13)=ax0; { Index of data in 7+8+18 (low 4 bits)} ax0=32; dm(status_buf+14)=ax0; { Modified time tag back to PC } ax0=0; dm(status_buf+15)=ax0; { FFT block exponent } ax0=32; dm(status_buf+16)=ax0; { PF - Programmable Flags } ax0=2; dm(status_buf+17)=ax0; { Remain 2; used as valid data check } ax0=18; dm(status_buf+18)=ax0; { Low 8 bits of PM (see +7) } ax0=1; dm(status_buf+19)=ax0; { This should remain as 1 always } The transmit status is a 10 byte block that is sent only during untriggered modes. This status block is 10 bytes long and prefixed by two more bytes ESC 'T'. Undefined bytes (at this writing) are filled with '0'. The bytes are: dm(xmit_status_buf+0)=xmit max amplitude L; dm(xmit_status_buf+1)=xmit max amplitude H; dm(xmit_status_buf+2)='0'; dm(xmit_status_buf+3)='0'; dm(xmit_status_buf+4)='0'; dm(xmit_status_buf+5)='0'; dm(xmit_status_buf+6)='0'; dm(xmit_status_buf+7)='0'; dm(xmit_status_buf+8)='0'; dm(xmit_status_buf+9)='0';