AN2085
AN2085
AN2085/D
Rev. 0, 11/2000
E-mail:
support@[Link]
Japan:
Freescale Semiconductor Japan Ltd.
Headquarters
ARCO Tower 15F Information in this document is provided solely to enable system and software
1-8-1, Shimo-Meguro, Meguro-ku, implementers to use Freescale Semiconductor products. There are no express or
Tokyo 153-0064 implied copyright licenses granted hereunder to design or fabricate any integrated
Japan circuits or integrated circuits based on the information in this document.
0120 191014 or +81 3 5437 9125 Freescale Semiconductor reserves the right to make changes without further notice to
any products herein. Freescale Semiconductor makes no warranty, representation or
[Link]@[Link] guarantee regarding the suitability of its products for any particular purpose, nor does
Freescale Semiconductor assume any liability arising out of the application or use of
Asia/Pacific: any product or circuit, and specifically disclaims any and all liability, including without
Freescale Semiconductor Hong Kong Ltd. limitation consequential or incidental damages. “Typical” parameters which may be
Technical Information Center provided in Freescale Semiconductor data sheets and/or specifications can and do
2 Dai King Street vary in different applications and actual performance may vary over time. All operating
Tai Po Industrial Estate parameters, including “Typicals” must be validated for each customer application by
customer’s technical experts. Freescale Semiconductor does not convey any license
Tai Po, N.T., Hong Kong under its patent rights nor the rights of others. Freescale Semiconductor products are
+800 2666 8080 not designed, intended, or authorized for use as components in systems intended for
[Link]@[Link] surgical implant into the body, or other applications intended to support or sustain life,
or for any other application in which the failure of the Freescale Semiconductor product
For Literature Requests Only: could create a situation where personal injury or death may occur. Should Buyer
Freescale Semiconductor Literature Distribution Center purchase or use Freescale Semiconductor products for any such unintended or
P.O. Box 5405 unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor
and its officers, employees, subsidiaries, affiliates, and distributors harmless against all
Denver, Colorado 80217 claims, costs, damages, and expenses, and reasonable attorney fees arising out of,
1-800-441-2447 or 303-675-2140 directly or indirectly, any claim of personal injury or death associated with such
Fax: 303-675-2150 unintended or unauthorized use, even if such claim alleges that Freescale
LDCForFreescaleSemiconductor@[Link] Semiconductor was negligent regarding the design or manufacture of the part.
The data communication between the DSP and a host computer is one of the important issues in designing
DSP-based systems directly connected to PCs which are commonly used as process controllers or as
interactive user interfaces. This application note proposes the implementation of a high-performance, yet
relatively simple, parallel data communication protocol for a DSP connected to a PC.
This document focuses on the implementation of the Extended Capabilities Port (ECP) parallel
communication standard on the DSP56300 family processors.
Specific ECP communication protocols are described along with the characteristic hardware and software
Freescale Semiconductor, Inc...
implementation details, both on the DSP and on the PC side. The performance evaluation routines
designed for the ECP data link are also presented, along with the corresponding results and conclusions.
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
10 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Freescale Semiconductor, Inc...
1 Introduction
An important set of real-life digital signal processing applications involves a host computer functioning as
a system controller or interactive graphical user interface. In these applications, reliable, high-speed data
communication between the DSP and the host computer is an important design and implementation issue.
This document describes the implementation of a high-performance, yet relatively simple, parallel data
communication protocol for a DSP connected to a PC. The paper focuses on the implementation of the
Extended Capabilities Port (ECP) parallel communication standard on the DSP56300 family processors.
Freescale Semiconductor, Inc...
Specific ECP communication protocols are described, as well as hardware and software implementation
details for both the DSP and the PC. Performance evaluation routines designed for the ECP data link are
also presented, along with corresponding results and conclusions.
Details of the ECP standard can be found in the Microsoft document, Extended Capabilities Port:
Specifications, Revision 1.06.
Introduction
For More Information On This Product,
Go to: [Link]
Freescale Semiconductor, Inc.
Input/
Pin SPP Signal ECP Signal Function
Output
1 Strobe HostCLK Output A low on this line indicates valid data at the host. When this pin
is de-asserted, the +ve clock edge should be used to shift the
data into the peripheral.
10 Ack PeriphCLK Input A low on this line indicates valid data at the peripheral. When
this pin is deasserted, the +ve clock edge should be used to
shift the data into the host.
11 Busy PeriphAck Input In reverse channel operation, a high on this pin indicates a
data cycle, while a low indicates a command cycle. In forward
Freescale Semiconductor, Inc...
12 Paper Out / End nAckReverse Input The peripheral pulls this pin low to acknowledge a reverse
request.
14 Auto Linefeed Host Ack Output In forward channel operation, a high on this pin indicates a
data cycle, while a low indicates a command cycle. In reverse
channel operation, the pin functions as HostAck.
15 Error / Fault PeriphRequest Input The peripheral pulls this pin low to indicate that reverse data is
available.
16 Initialize nReverseRequest Output This pin is pulled low to indicate that data is in the reverse
direction.
17 Select Printer 1284 Active Output The host pulls this pin high to indicate 1284 transfer mode, and
pulls the pin low to terminate.
HostClk
PeriphAck
HostAck
Data
HostClk
PeriphAck
HostAck
Data
nReverse Request
nAckReverse
PeriphClk
HostAck
PeriphAck
Data
nReverse Request
nAckReverse
PeriphClk
HostAck
PeriphAck
Data
Base + 0 Data (SPP) Read/Write Standard parallel port data register. Writing to this
register in SPP mode drives data on the parallel port
data lines. In all other modes the drivers can be
tri-stated by setting the direction bit in the Control
Register.
ECP Address FIFO (ECP mode) Read/Write Data written to this address is placed in the FIFO and
tagged as ECP Address/RLE. ECP port hardware
transmits the byte to the peripheral automatically.
Base + 1 Status Register Read Reflects the inputs on the parallel port interface.
Base + 2 Control Register Read/Write Directly controls several output signals, sets the direc-
Freescale Semiconductor, Inc...
Base + 400h Data FIFO (Parallel Port FIFO Mode) Read/Write In Parallel Port FIFO Mode, any data written to the
Data FIFO is sent to the peripheral using the SPP
handshake; hardware generates the handshaking
required.
Data FIFO (ECP Mode) Read/Write When data direction is 0 (output to peripheral), bytes
written or DMAed from the system to this FIFO are
transmitted to the peripheral by hardware handshake
using the ECP parallel port protocol. When data direc-
tion is 1 (input from peripheral), bytes from the periph-
eral are read into this FIFO under automatic hardware
handshake from ECP.
Test FIFO (Test Mode) Read/Write Data can be read, written, or DMAed to or from the
system to this FIFO in any direction; data is not trans-
mitted to the parallel port lines using a hardware pro-
tocol handshake but can be displayed on the parallel
port data lines.
Configuration Register A (Configuration Mode) Read/Write Indicates if the card generates level- or edge-trig-
gered interrupts and the bus widths within the card,
and determines if there are any bytes left in the FIFO.
Configuration Register A is accessible only when the
ECP Port is in Configuration Mode.
Base + 401h Configuration Register B (Configuration Mode) Read/Write Selects compression option (RLE) for outgoing data,
returns the status of the IRQ pin, IRQ assignment and
DMA Channel assignment. Configuration Register B
is accessible only when the ECP Port is in Configura-
tion Mode.
Base + 402h Extended Control Register Read/Write Configures the ECP mode and returns the status of
the ECP FIFO. Modes of operation include:
• Standard Mode
• Byte / PS/2 Mode
• Parallel Port FIFO Mode
• ECP FIFO Mode
• EPP Mode
• FIFO Test Mode
• Configuration Mode
1 33 HAS/A0
14 21 HDR/WR
2 43 HAD0
15
3 42 HAD1
16 30 HCS/A10
4 41 HAD2
17
5 40 HAD3
18
6 37 HAD4
19
Freescale Semiconductor, Inc...
7 36 HAD5
20
8 34 HAD6
21
9 34 HAD7
22
10 32 HA8/A1
23
11 31 HA9/A2
24
12 22 HRW/RD
25
13
In this implementation, all HI08 signals are configured as General Purpose I/O lines (GPIO) during the
ECP initialization routine for the DSP. The Host Interface data lines (HAD0–HAD7) are assigned to the
ECP data bus (D0–D7). The ECP handshake signals are connected to the HI08 port as shown in Table 3.
Table 3. ECP to HI08 Pin Assignments
HostClk HAS/A0
Data 0–7 HAD0–HAD7
PeriphClk HA8/A1
PeriphAck HA9/A2
nAckReverse HRW/RD
HostAck HDS/WR
nReverseRequest HCS/A10
In some cases, the electrical signal coupling between the DSP and the host computer may require voltage
level shifters to accommodate the 3.3V DSP56300 family I/O port voltage levels and the 5V (TTL) parallel
interface signals of the host computer. Tests run with the ECP implementation on the DSP56303 issued
satisfactory results without such voltage level interface buffers, but special care must be taken with each
DSP56300 family device.
5.1.1 Initialization
The DSP initialization routine includes:
• Configuring the HI08 port as GPIO
• Setting the direction of each line used for handshaking
• Generating the correct logical levels on the output lines
• Initializing the HI08 lines that connect to the ECP data bus as inputs
The code for this routine is presented in Example 1.
bset nACKREVERSE,x:hdr
bclr HOSTACK,x:hddr
bclr nREVERSEREQUEST,x:hddr
bsr line_in
rts
Start Read
nRevReq=LOW Yes
?
No
PeriphClk HIGH
Yes nRevReq=LOW
?
No
Freescale Semiconductor, Inc...
Yes
HostClk=HIGH
?
No
PeriphAck HIGH
Yes
nRevReq=LOW
?
No
Yes
HostClk=LOW
?
No
PeriphAck LOW
End Read
In accordance with ECP specifications, the read routine performs a blocking scan of the nReverseRequest
(‘data direction’) and HostClk (‘data valid’) lines. If the host pulls the data direction line low, indicating a
host request to read data from the DSP, a “time-out” condition occurs; the program exits the read routine
and goes to the write routine. Otherwise, the read routine waits for a byte to be sent by the host, indicated
by a high on the HostClk line.
The code for the read routine is given in Example 2 on page 12.
read_end
rts
data_in
move x:hdr,a0 ;Get one byte from data
extractu #$8000,a,a ;;bus and store it in a0.
rts
Start Write
Yes
nRevReq=HIGH
?
No
nAckRev LOW
Call DataOut
PeriphAck HIGH
Freescale Semiconductor, Inc...
PeriphClk LOW
Yes
nRevReq=HIGH
?
No
Yes
HostAck=LOW
?
No
PeriphClk HIGH
Yes
nRevReq=HIGH
?
No
Yes
HostAck=HIGH
?
No
Call LineIn
PeriphAck LOW
nAckRev HIGH
END Write
The write routine performs a non-blocking scan on the nReverseRequest (‘data direction’) handshake line.
If the line is high, indicating that the host is in the Forward Data phase of ECP operation and is not ready to
receive the data byte from the DSP, the program exits the write routine and goes to the read routine.
Otherwise, the write routine sends the byte out on the ECP data bus.
The code for the write routine is given in Example 3.
Example 3. ECP Write Routine Code
write
jset #nREVERSEREQUEST,x:hdr,write_end ;If nRevReq line is low,
bclr #nACKREVERSE,x:hdr ;;exit from write routine,
;;else reset nAckRev,
bsr data_out ;;output the data on data
;;lines.
bset #PERIPHACK,x:hdr ;Assert PeriphAck,
bclr #PERIPHCLK,x:hdr ;;de assert PeripClk.
wr1
jset #nREVERSEREQUEST,x:hdr,time_out_wr
Freescale Semiconductor, Inc...
data_out
move a0,x0 ;Take the least
;;significant byte from
move x:hdr,a0 ;;a0 and send it,
insert $8000,x0,a ;;without modifying
move a0,x:hdr ;;the most significant
move x:hddr,a1 ;;byte from Host Data
or $ff,a ;;Register.
movev a1,x:hddr
rts
Example 5 lists the reverse mode ECP test routine on the DSP.
Example 5. DSP-Side Performance Evaluation Routine—Single-Byte Transfer, Reverse Mode
ECP_test ;Test the ECP Reverse phase
bsr init_ecp ;Initialize the HI08
again
move b,a
jsr write ;Write a byte (from a0) to the host
inc b ;Increment the value
jmp again ;Infinite loop
}
}
t2=time(NULL); //Store the transfer end time
printf(“\nErrors=%d”,error_no); //Display the error counter and
printf(“\nSpeed=%f”,(double)4096000.0*16.0/(t2-t1)); //transfer speed
}
The difference between the forward mode and reverse mode transfer rates in Table 4 is due to the fact that
the reverse data routine requires more DSP instruction cycles than the forward data routine.
In the same manner, one can easily implement the corresponding ‘Receive_Buffer’ routine on the DSP
using the ‘read’ routine described in Example 2 on page -12.
To transfer 16-bit words, the ‘Send_Buffer’ routine can be modified as shown in Example 8. Similar
modifications can be used for forward transfers, and to send or receive 14-bit words.
Example 8. 16-bit Word Buffer Send Routine
Freescale Semiconductor, Inc...
Send_Buffer_16
move #buffer,r0
do #buf_len,loop_sb
move x:(r0)+,a0
bsr write
extract #$8008,a,a ; Replace the 8 least significant bits in A0 with the
;; next 8 more significant ones, to be used further
;; by ‘write’.
bsr write
loop_sb
rts
Data
Address
Expansion Port
(Port A)
RD
WR Data
AAX CS
ECP Host ECP Status
Controller Interface
DSP563XX DMAREQ
IRQX
Control
DMADIR
HI08 DMAACK
(Port B)
Freescale Semiconductor, Inc...
Configured TC
as GPIO
As the master of the ECP data link, the host computer uses the ECP control lines to select the type of data
transfer (forward or reverse) and initiates the transactions. Thus, the ECP Controller always initiates the
DMA cycles with the DSP by asserting DMAREQ (DMA transfer request) and DMADIR (direction of the
transfer). The actual DMA transfer begins when the DSP asserts DMAACK (DMA transfer acknowledge)
and CS. The DMA transaction ends when the DSP asserts the TC (terminal count) signal.
On the DSP side, some preliminary configuration and initialization is required to perform DMA
transactions with the ECP controller, including the following steps:
• Port A Data lines are used for data transfers.
• Port A Address lines specify the location of the transferred data.
• Port A RD and WR signals command the read and write cycles, respectively.
• Port A AAx (One of the four Address Attribute 0:3 lines functions as the chip select signal for the
ECP controller.
• Interrupt line IRQx serves as the DMA request signal from the ECP controller.
• An interrupt handler for the DMA request is installed.
• Three HI08 (Port B) signals are configured as GPIO to function as follows:
— DMAACK (output)
— DMADIR (input)
— TC (output)
When the host initiates an ECP reverse data cycle, (i.e., reads a data buffer from the DSP), the following
steps are executed:
1. Host configures the ECP controller and initiates the ECP reverse data cycles.
2. ECP controller asserts DMAREQ.
3. The DSP interrupts the execution of its current program and handles the corresponding
interrupt as follows:
8 Conclusion
The ECP interface enables medium to high-speed parallel data transfers between a host computer and a
DSP-based application without the physical limitations of a direct connection between the data buses of the
host and DSP. This solution is easy to implement, requiring little or no additional hardware beyond the
standard DB25 parallel connector and minimal software development. System performance can be
enhanced by using DMA transfers between the host ECP controller and the DSP.
10 References
Freescale Semiconductor, Inc...
[1] DSP56300 Family User’s Manual (order number DSP56300FM/AD), Motorola, Incorporated, 1999.
[2] DSP56303EVM User’s Manual (order number DSP56303EMUM/AD), Motorola, Incorporated, 1999.
[3] DSP56307EVM User’s Manual (order number DSP56307EVMUM/D), Motorola, Incorporated, 1999.
[4] DSP5630x Port A Programming, Application Note (order number AN1751/D), Motorola, Incorporated,
1999.
[5] Motorola DSP Assembler Reference Manual, Motorola, Incorporated, 1996.
[6] IEEE Standard Signaling Method for a Bidirectional Parallel Peripheral Interface for Personal
Computers, Draft D1.1, November 5, 1999, Institute of Electrical and Electronic Engineers, Inc.
[7] Extended Capabilities Port: Specifications, Revision 1.06, July 14, 1993, Microsoft Corporation.
[8] Interfacing the PC. Interfacing the Extended Capabilities Port, Craig Peacock, February 28, 2000,
Internet Resource.
[9] W91284PIC. IEEE 1284 Peripheral Interface Controller. Data Sheet, Revision 4.00, 29 October, 1999,
Warp Nine Engineering.
[10] High Performance ECP/EPP Printer Interface Using the PPC34C60 PPIC, Jeffrey C. Dunnihoo,
Application Note 4.17, Revision 13 January, 1994, Standard Microsystems Corporation.