Skip to content

Just For The Record – Overrunning the TP3465V

January 24, 2016

16-01-24 too fast

I wanted to verify the timing with the Z80 and the SPI bus both clocked at 4mhz.  I set up a sequences of Z80 OUT instructions with and without intervening noops.  the pair on the left clearly interfered with extra clocks and garbled output.  The pair on the right, with one intervening no-op are clearly ok.  Mat Millman pointed out a trick for running the TP3465V in 16 bit mode to tighten up the timing but hopefully it won’t come to that.  The speed of the Z80 getting data ready is more likely to be an issue in a real program: the current spisendN() routine takes about 11 Z80 instructions or 13uS/byte=75K/second. I’ll see whether that seems like an issue with ethernet and  the 16 bit mode might help with that too.

16-01-24 not too fast

void spiSendN(unsigned char* loc, unsigned int N){ //this is for output only
//following code pretty much copied from compiler output for above with out(... replaced by inline assembly;C:\Users\Bill\Desktop\olduinoZ\hwspilcd\/hspi2.c:80: while(N!=0){
//i'm quite sure it could be done better
__asm
	ld	hl, #4
	add	hl, sp
	ld	e, (hl)
	inc	hl
	ld	d, (hl)
	ld	hl, #2
	add	hl, sp
	ld	c, (hl)
	inc	hl
	ld	b, (hl)
;here the count is in de and the sending location is in bc
1$:
	ld	a,d
	or	a,e
	ret	Z
;out(0x81,*loc);
	ld	a,(bc)
	out (#0x81),a
;N--;
	dec	de
;loc++;
	inc	bc
	jr	1$
__endasm;
	N;loc;	//these don't do anything but they keep the compiler happy

}
void spiReceiveN(unsigned char* loc, unsigned int N){ //this is for input only
//following code pretty much copied from compiler output for above with out(... replaced by inline assembly;C:\Users\Bill\Desktop\olduinoZ\hwspilcd\/hspi2.c:80: while(N!=0){
//i'm quite sure it could be done better
__asm
	ld	hl, #4
	add	hl, sp
	ld	e, (hl)
	inc	hl
	ld	d, (hl)
	ld	hl, #2
	add	hl, sp
	ld	c, (hl)
	inc	hl
	ld	b, (hl)
;here the count is in de and the receiving location is in bc
1$:
	ld	a,d
	or	a,e
	ret	Z
;*loc=in(0x81);
	out	(#0x81),a	;trigger a transfer
	nop				;added 16-01-23 to allow tp3465 to respond
	in	a,(#0x81)	;retrieve the result
	ld	(bc),a		;store it
;N--;
	dec	de
;loc++;
	inc	bc
	jr	1$
__endasm;
	N;loc;	//these don't do anything but they keep the compiler happy
}

 

Advertisements

From → Olduino/Z

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: