Parallel library for Due External Memory Bus/Static Memory Controller

Brilliant work - after setting some conservative timings it worked first time :grin:

I am using a 128KByte SRAM (AS6C1008) so only used the first 17 address lines. I didn't use NRD, I just tied the OE pin low (a write cycle still works with OE low - OE is active low)

#include <Parallel.h>

void setup() {

  Parallel.begin(PARALLEL_BUS_WIDTH_8, PARALLEL_CS_0, 17, false, true);
  Parallel.setCycleTiming(16,16);
  Parallel.setPulseTiming(4,4,4,4);
  Parallel.setAddressSetupTiming(4,4,4,4);
  
  Serial.begin(115200);
}

void loop() {

  int t=micros();
  
  randomSeed(t);
  
  Serial.print("WRITE seed="); Serial.print(t);
  for(int a=0;a<131072;a++)  Parallel.write(a,random(256));
  Serial.println(" done");

  randomSeed(t);
  Serial.print("READ ");
  for(int a=0;a<131072;a++){
    int d=Parallel.read(a);
    int r=random(256);
    if(d!=r){
      Serial.println();
      Serial.print("Error at address ");
      Serial.print(a,HEX);
    }
  }  
  Serial.println("done"); 
}
WRITE - seed=679868002 done
READ done
WRITE - seed=680429926 done
READ done
WRITE - seed=680991852 done
READ done
WRITE - seed=681553778 done
READ done
WRITE - seed=682115712 done
READ done
WRITE - seed=682677638 done
READ done

I could probably get the timings down lower but given the spaghetti on my breadboard perhaps that's not such a good idea 8)

update: got the timings down to

  Parallel.setCycleTiming(5,5);
  Parallel.setPulseTiming(4,4,4,4);
  Parallel.setAddressSetupTiming(1,1,1,1);

Given that it's a 55ns part I can't go any lower.

One last request: a getAddr() method :slight_smile: