Copyright 1999, Analog Devices, Inc. All rights reserved. Analog Devices assumes no responsibility for customer product design or the use or application of customers’ products
or for any infringements of patents or rights of others which may result from Analog Devices assistance. All trademarks and logos are property of their respective holders.
Information furnished by Analog Devices Applications and Development Tools Engineers is believed to be accurate and reliable, however no responsibility is assumed by Analog
Devices regarding the technical accuracy of the content provided in all Analog Devices’ Engineer-to-Engineer Notes.
A slave can use this feature to request the token
from the master. The master, through a link
Using Token Passing to
Control SHARC Link Port
Bi-directional
Communication
Last Modified:9/23/97
Contributed by:Richard G.
service request interrupt service routine, recognizes
the request for the token and decides whether or not
to release the token to the slave. Releasing the
token causes the master to set up its link port to
receive thus becoming a slave. The slave, having
verified that it has been given the token, will then
set up its link port to transmit and becomes the
master.
Using the Link Token Pass
Overview
Link port communication on the SHARC is bidirectional and can be switched at runtime through
software control. For bi-directional communication
to work, each link port must know which is the
transmitter and which is the receiver at any given
time. You can use token passing to accomplish this
type of software control. This document describes
how the link token pass example code implements
token passing on the SHARC.
Token Passing
Token passing is a software control scheme
designed to control the direction of communication
between two or more devices. It enables a program
to establish a master, or transmitter, in a given
communication system and to transfer that
mastership to any of the slaves at a given time.
The token, a software flag, resides in the master
link port and can be released to a slave upon
request or at the discretion of the master.
The link ports of the SHARC implement this
protocol through the link service request interrupt.
To use the link token pass example code, you must
load it on both the original master and the original
slave. The example code is ID intelligent for
multiprocessor systems: ID#1 is the original master
(transmitter) and ID#2 is original slave (receiver).
To implement token passing, the example code
follows this procedure:
1) The master transmits a buffer via DMA through
LPORT0 using LBUF3, and the slave receives
through LPORT0 using LBUF2.
2) The slave requests the token by generating an
LSRQ (link port service request) interrupt in the
disabled link port of the master (LPORT0).
3) The master responds by sending the token
release word and waits to see if it is accepted.
4) The slave checks the token release word and
accepts the token by emptying the master's link
buffer FIFO within a predetermined amount of
time.
a
5) If the token is accepted the slave becomes the
master and transmits a buffer of data to the new
slave. If the token is rejected, the master transmits
a second buffer.
6) When the transmission is complete the original
master finishes by setting up LBUF2 to receive
without DMA, and the original slave sets up
LBUF3 to transmit without DMA.
When implementing a software protocol for token
passing, it is important to note the following:
• Make sure that only one link buffer is enabled
to transmit at a time. Otherwise data will be
lost since neither link port will drive LxACK.
The example code polls the LSRQ register
status bits to ensure that the master becomes
the slave before the slave becomes the master
to avoid the two transmitter conflict.
• When using the status bits of the LSRQ register
for status detection and a link port that is
configured to receive is disabled, there will be
an RC delay before the 50k ohm pull-down
resistor on LxACK can pull the value below
logic threshold. In this instance, if the LxTM
(link port transmit request) bit is set in the
LSRQ register, then an LSR (link port service
request) will be latched and the LSRQ interrupt
may be generated unintentionally.
• In an application that uses timing control loops
to synchronize parallel code execution (such as
the example code), synchronization must not be
disrupted by unrelated influences at critical
sections. Disabling interrupt nesting is one of
the techniques the example code uses to control
synchronization.
/*_____________________________________________________________________________
ADSP-2106x LINK Token Pass Example
_______________________________________________________________________________*/
#include "def21060.h"
#define N 8/* Size of buffer*/
#define trw 0x0/* Token release word*/
#define orig_master_id 1/* ID of SHARC to be original master*/
#define orig_slave_id 2/* ID of SHARC to be original slave*/