[comp.sys.next] DSP help needed

rwb@vi.ri.cmu.edu (Bob Berger) (06/21/89)

I need to write some dsp routines that process arrays of data.
I wrote a simple test program which reads an array from the host
interface into DSP memory, then writes the array back to the host
with each element shifted. The program works when I put the array
into the DSP's on chip memory, but fails when I try to use the off chip
memory at $2000. When it fails, all of the elements returned are
copies of the last element written to the memory, as if the memory
were not enabled or something.

What am I doing wrong?

Here's my code:

; array56k.asm  DSP bootstrap program that reads an array,
; right shifts each element, and sends the array back to the host

		org p:0 
reset	jmp >rcv_cnt

	dup $40-2	; output must be a contiguous segment
	nop
	endm

	org p:$40	;  starting address

rcv_cnt jclr #0,x:$FFE9,rcv_cnt	; wait for data from host 
	move x:$FFEB,R0		; RO = count
	
	move #$2000,R1		; R1 = array address in external memory
	
	do R0,end_rcv
rcv_dat jclr #0,x:$FFE9,rcv_dat	; wait for data from host
	move x:$FFEB,A1		; get word from host
	move A1,x:(R1)+		; put it in external memory
end_rcv
	
	move #$2000,R1		; R1 = array address in external memory

	do R0,end_xmt
	move x:(R1)+,A1		; get word from memory
	LSR A			; right-shift one place
xmt_dat jclr #1,x:$FFE9,xmt_dat	; wait for host ready
	move A1,x:$FFEB		; send shifted word to host 
end_xmt

	jmp rcv_cnt
	
	end $40
	


#include <dsp/dsp.h> 

int count = 5;
int data[] = {2,4,6,8,10};

main()
{ 
    int i;

    DSPBootFile("array56k"); 

    DSPPutTX(count);
    DSPPutTXArray(data,count);
    DSPGetRXArray(data,count);
	
    for (i = 0; i < count; i++)
	printf("%d ",data[i]);
    printf("\n");

    DSPClose(); 
}


-- 

eht@f.word.cs.cmu.edu (Eric Thayer) (06/21/89)

This code fragment configures the DSP environment 'properly.'  I believe that
you are right in saying that external ram seems to be disabled.  This fixed
my problems with using external ram.  The reset vector should be:
	jmp	>init

init    movec   #6,omr			;data rom enabled, mode 2
	bset    #0,x:m_pbc		;host port
	movep   #>$0001F7,x:m_pcc	;both serial ports (SC0 not available)
	bset	#3,x:m_pcddr		;   pc3 is an output with value
	bclr	#3,x:m_pcd		;   zero to enable the external ram
        movep   #>$004000,x:m_cra	;set up for external clock on DSP port
        movep   #>$002300,x:m_crb	;read L/~R on IF1
	movep   #>$000000,x:m_bcr	;no wait states on the external sram
        movep   #>$00B400,x:m_ipr  	;intr levels: SSI=2, SCI=1, HOST=0
_reset
-- 
Eric H. Thayer		Carnegie Mellon School of Computer Science
(412) 268-{8724,6973}	5000 Forbes Ave, Pittsburgh, PA 15213
--