Skip to content

Ethernet on the 4MHZ Olduino

June 23, 2014

With the 4MHz membership card cpu board working and the no-wait 4MHz SPI clock in place.  I hooked up the Ethernet board to try it out.  I was mostly just looking to see if it would work and it did but I was pretty struck by the speed.  This is the simplest version of the server code, it made almost no attempt to cut down page serving time but it is pushing an effective 500+bytes a second.  This may not sound like much but it’s about 3X faster than on the old hardware.  I think with a little work it will come down to a quarter second or so to send a 500 byte page which is where I’d like to be for public internet use.  The timing in the grey terminal window just shows me that it’s taking about .9 seconds to analyze the incoming page and serve a 500 byte response.

14-06-23 timing 14-06-23 server

 

The code fragments below are done the most straightforward way and involve a lot of call/return overhead.  Also, there’s no attempt to send multiple bytes out over spi.  each payload byte requires 4 calls to spiwrite which itself makes calls.  It all adds up something fierce.

//Sendform routine
	static char hdr[]="HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"
						"blah blah html"
						"blah blah more html";
						//approx 200 bytes
	printf(">SF\n");
	pagehits+=1;
	sendrc=send0s(hdr); 	// Now Send the HTTP Response first part
	printf("0\n");
//in send0s routine
	return send0((unsigned char *)what,strlen(what));
//in send0 routine
    while(buflen) {
      buflen--;
      // Calculate the real W5100 physical Tx Buffer Address
      realaddr = TXBUFADDR + (offaddr & TX_BUF_MASK);
      // Copy the application data to the W5100 Tx Buffer
      SPI_Write(realaddr,*buf);
      offaddr++;
      buf++;
    }
in SPI_Write routine
  enablewiz();   			// Activate the CS pin
  spiSend(WIZNET_WRITE_OPCODE);   // Send Wiznet W5100 Write OpCode
  spiSend(addr >>8); 		// Send Wiznet W5100 Address High Byte
  spiSend(addr & 0x00FF);	// Send Wiznet W5100 Address Low Byte
  spiSend(data);			// Send the data byte
  disablewiz();				// make CS pin not active
in spiSend routine
	asm("	glo 12\n" //get the char to send
		"	dec 2\n"  //make a work area
		"	str 2\n"  //place the outbound char
		"	out 6\n" //this loads the MOSR and starts the outboard clock
		"	cretn\n"
	);

The logic analyzer screen shot below shows the SPI clock during general polling and the 1 second period where it’s actually busy.
14-06-23 saleae 1

The section below shows part of the busy section in greater detail. You can see the 4 spurts of activity for each payload byte followed by a gap, all of which adds up to 1.5ms. The theoretical time for this is 32/4MHz= 8 *micro*seconds! I would aspire to getting to that 8 mics plus maybe 25 instructions which would be 25*16/4MHz or 108uS total, a 15 fold speedup. I’d be satisfied with half that improvement.
saleae2

Advertisements

From → web server

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: