Dick Cappels' project pages http://www.projects.cappels.org

return to HOME


DS interface test tool

(Data transfer via handshake test tool)

The DS protocol was designed to provide firmware-based bidirectional host-to-slave inter processor communications for situations in which no hardware solution is available and the host and/or the slave in incapable of tending the interface in real time. The only specialized hardware required is two bidirectional I/O ports on each chip (alternatively two input ports and two tri-statable output ports may be used. In other words, it provides some of the functionalit of the Two-Wire-Interface (TWI,  or I2C as named by Philips) where an actual TWI is not feasible in either hardware or firmware.

For details of the DS protocol please see this page.


AVR Studio Assembly Source code (HTML -cut and paste into your assemble editor)

AVRStudio hex file

MacAVRPA hex file

Note: Hex files assume 4 Mhz crystal, communications with terminal at 9600 baud, 1 stop bit, no parity.

User map (.PDF file)

Hardware considerations:


The 5 volt power pin on the DS interface may be used to supply power to the DS device being tested. In this case, a power on-off switch would be a good idea. The microcontroller timing is unimportant for the DS device, but it is critical for the baud rate generator on the AT902313. The RS-232 inverters could also be Maxim MAX-232 or something similar. I prefer these discreet inverters because I am building them by hand and they take less board space than the DIP buffers.

On the DS interface side, the firmware provides for week internal pullups on the Attention and Data lines, so no nexternal resistors are required unless there is a large capactive load on these lines, in which casce, resistors as low as 270 Ohms may be used.


Examples of use of the tool.

The test tool provides a means of reading and writing data and commands to a DS slave device and displays data sent from a DS slave as it is received.

Writing to a register

Coming out of reset, a menu is displayed:

   DS Interface test tool 03 November 2002 Dick Cappels

Space bar = Enter value
M or m = Send value as data
/ = Send value as command
S = Send value from keyboard to register
D = Dump registers 0..F
<RETURN> = Print last value buffer
T or t = Set DS port delay parameter
! = reset chip
? = Display menu
All address and values are hexadecimal and are byte wide

Current delay value = $20 20


The colon (:) prompt indicates that a command or daya may be entered. Note that if DS port delay parameter had not been set since the EERPOM was erased, the default will be $FF $FF which is very slow. You might want to adjust the delay parameter. with the T command until the Dump command is fast but reliable.


Enter the data value. press the space bar and receive the prompt:

   :  Enter Value: 

Enter the data value, in this case A5:

: Enter Value: $A5
A5 :

The DS tool will respond by echoing the value (A5).


Send the the data as a data transmission to the DS device by pressing the "m" key.

   :  Enter Value: $A5
A5 : :

DS tool will respond with a colon (:).



Send the command to store the data byte just sent to the device in the input register for DAC 0 by entering the command 10. To send the command, press the space bar, enter the comand "10" at the prompt,then press the forward slash key to send the command. The 1 is the instruction to store the data into a register and the 0 is the address that designates the input register for DAC 0.

   :  Enter Value: $A5
A5 : : Enter Value: $10
10 : :

At this point, the value $A5 has been stored in register 0.


An alternative means of setting the value of registers $0..$F is by using the S command.

   :  Enter Value: $3a Enter register to send data to ($0..$F):2  Data Sent.

The S command replicates the sequence of using the space bar and the forward slash command and adds prompts.


Reading a register


At the colon prompt, press the space key and receive the "Enter Value" prompt.

:  Enter Value:


Type "22" on the keyboard


:  Enter Value: $22

22 :

The tool will echo "22" the screen.


Press the forward slash key ("/") .

:  Enter Value: $22

22 : Command Sent.


5A :

The notification, "Command Sent" will appear when the command has been sent, followed by a colon prompt. The value contained in register $2 will be despalayed when it is received from the DS slave device, followed by another colon prompt. In the example above, the data read from register $2 in the slave device has the value of $5A.


Command summary

Space bar = Enter value
After the prompt, enter a value to be sent as either as data to the Incoming Data Register in the
DS slave device, or as a command to the DS slave device. The data is one hexadecimal byte in the range $00..$FF.

M or m = Send value as data

Send the last value to the DS slave device as data. This is the latest of two sources: data a value from the keyboard after pressing the space bar, or data received by a read command.. To illustrate the point, data can be written to one register in a DS slave device, then read from back from it then copied to another register with the following sequence:

FF :  Enter Value: $5A            (space bar pressed and $5A entered)
5A : Data Sent. (letter "M" was pressed, sending the data to the slave)
: Enter Value: $10 (space bar pressed and $10, command to store in reigister 0 entered)
10 : Command Sent. (forward slash was pressed, sending the command)
: Enter Value: $20 (space bar pressed and $20, command to read register 0 entered)
20 : Command Sent. (forward slash was pressed, sending the command)
5A : Data Sent. (data, $5A from register 0 displayed, m pressed, sending it out again)
: Enter Value: $11 (space bar pressed and $11, command to store in reigister 1 entered)
11 : Command Sent. (forward slash was pressed, sending the command)
: (letter "D" was pressed, dumping the 16 slave registers)

0 5A
1 5A
2 00
3 FF
4 5A
5 5A
6 00
7 00
8 FF
9 FF
E 0C

Register 0 contains the $5A originally written and reigster 1 contains $5A as copied from register 0.

/ = Send value as command

Send value entered from keyboard via the spaebar command or just received from the DS slave device as a command to the DS slave device.

S = Send value from keyboard to register

Gets data from the keyboard and sends to a DS slave register as indicated in the response to prompts. Easy to use to enter data into registers but not flexible.

D = Dump registers 0..F

Displays the contents fo the 16 DS slave device registers.

<RETURN> = Print last value buffer

Prints the restulst the latest of two sources: data a value from the keyboard after pressing the space bar, or data received by a read command.

T or t = Set DS port delay parameter

Enter hexadecimal two bytes in response to the prompt and the values will be use by the tool and stored in the on-chip EEPROM for use the next time the chip is reset or power is applied. On a freshly programmed chip the value will be $FF $FF, which resulst in noticable slow response.

A delay time is used in the bit level protocol to allow for settling of the attention and data lines and provide adquate time for the attention line to be sampled by the receiving device. Too short of a delay will result in the interface lockign up. Too long of a delay will slow things down a lot. There are theoretically some "magic" delays, that depend on the clock rates of the master and salve devices that will result in very long transmission times -these are analogous to beats between harmonics of the sampling rates. The delay values are not cricital. Select the delay numbers that provide the fastest robust performance.

! = reset chip

Forces a reset of the chip using the watchdog timer. This has limited utility as it cannot be used to recover from a hung interface.

? = Display menu

Displays the menu of keyboard commands.

Note that all address and values are hexadecimal and one byte wide.


Free Republication Rights

This document and protocol may be republished freely provided that proper attribution is given and notification of publication is sent to projects@cappels.org.. Take note of the liability disclaimer on the HOME page.

HOME page