Arduino Forum

Products => Arduino Due => Topic started by: delsauce on Mar 06, 2013, 11:16 pm

Title: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: delsauce on Mar 06, 2013, 11:16 pm
This library enables the External Memory Bus/Static Memory Controller on the Arduino Due board. It's more of an external memory interface than a true parallel port.

The DUE board pins out the data bus on the extended digital headers (D0-D7:PIN34-PIN41) along with the control signals NCS1 and NWR. Some of the address signals are connected to the PWM pins (A0-A5), but a full address bus is unavailable. There is also conflict between the SS1 pin for SPI, A5, and the NRD signal used for the parallel bus. In short the hardware wasn't designed for use with external parallel memories.

The library does allow connection to some of the lower resolution LCD controllers that used index addressing and can speed up read/write times considerably in some situations.

Code is hosted up on git.
https://github.com/delsauce/ArduinoDueParallel (https://github.com/delsauce/ArduinoDueParallel)
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: graynomad on Mar 07, 2013, 04:43 am
Quote
In short the hardware wasn't designed for use with external parallel memories.

Something I spotted early in the peice and will never understand.

______
Rob
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: delsauce on Mar 07, 2013, 07:14 am
It would have been a nice surprise to see an address/data bus pinned out, but this was the first foray for the Arduino folks into a much more complicated processor.  The overall goal of simplicity is critical and I guess this feature wasn't above the bar for the first ARM board.  It's certainly a balancing act to get everything in there. 

On top of that, this part isn't nearly as configurable as some of Atmel's homegrown 32-bit parts, the UC3 family.  In those parts each function can go to sometimes as many as 6 different pins.  In the SAM3X, many functions only have a single pin option, maybe two if you're lucky.

Anyhoo, there is still some limited use of the EMB/SMC in the current DUE...
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: stimmer on Mar 07, 2013, 01:10 pm
Could you add the other address lines anyway, even though some are missing? And do you know which is connected where and which are missing? I think A9 was wired to an LED so is inconvenient but I don't know about the others. You could possibly alter the read/write methods to shuffle the address to avoid the missing bus lines.

Also it's not completely impossible for a very determined hacker to solder to an unconnected pin if you take care to mask off the other pins close by (and know how to get yourself out of trouble when it goes wrong :) )

I don't think the NRD clash is such a big problem, the timing can be deduced from NWR and CS.

The upcoming version of the VGA library uses DMA to the SMC data bus to generate the colour modes, with the signal timings controlling the pixel rate.
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: graynomad on Mar 07, 2013, 01:17 pm
I haven't looked for a while but I thought the only show stopper was A5 or maybe A6, all the other pins are broken out IIRC. So I think a determined hacker could solder onto that pin.

I don't remember A9 on a LED but that maybe, which case ditch the LED.

_____
Rob
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: delsauce on Mar 07, 2013, 04:08 pm
Here are most of the SMC pins and how they are connected.  I left out the NAND flash stuff and didn't double check for accuracy...

Address Bus:


























Function Chip PinArduino Pin
A0PC21PWM9
A1PC22PWM8
A2PC23PWM7
A3PC24PWM6
A4PC25PWM5
A5PC26PWM4
A6PC27N/C
A7PC28PWM3
A8PC29PWM10
A9PC30RX LED
A10PD0PIN 25
A11PD1PIN 26
A12PD2PIN 27
A13PD3PIN 28
A14PD4TXD0
A15PD5RXD0
A16PD6PIN 29
A17PD7PWM11
A18PA25MISO
A19PA26MOSI
A20PA27/PA18SPCK/SCL1
A21PD8PWM12
A22PD9PIN 30


Here is the data bus:



















Function Chip PinArduino Pin
D0PC2PIN 34
D1PC3PIN 35
D2PC4PIN 36
D3PC5PIN 37
D4PC6PIN 38
D5PC7PIN 39
D6PC8PIN 40
D7PC9PIN 41
D8PC10N/C
D9PC11N/C
D10PC12PIN 51
D11PC13PIN 50
D12PC14PIN 49
D13PC15PIN 48
D14PC16PIN 47
D15PC17PIN 46


And the control signals:









Function Chip PinArduino Pin
NRDPA29(also tied to PC26 on PCB, which is A5)SS1/PWM4
NWEPC18PIN 45
NCS0PA6AD4
NCS1PA7PIN 31
NCS2PB24N/C
NCS3PB27PWM13


There isn't too much you can do with the A5/NRD problem in software since the two pins are wired together on the PCB (I am not sure why those pins are wired together...)  If you were careful, you could cut the trace on the bottom side of the board...

I can pretty easily add all the pins to the library and let the user sort out any conflicts.
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: stimmer on Mar 07, 2013, 05:00 pm
Thanks :) If you add the addresses to the library I'll check it with a SRAM.

I managed to attach to the pin for port C 27 without soldering 8) You need an IC pigtail clip like this:

http://www.coolcomponents.co.uk/catalog/hook-with-pigtail-p-805.html

Straighten the ends a little with sharp-nose pliers and cut a little off the plastic sheath, and cover the outsides of the ends with an etch-resist pen to insulate from the adjacent pins. Use this sketch to help you get the right pin.

Code: [Select]
// Address A6 / Port C 27 test by stimmer

// Port C 27 is above the right edge of the SPI connector
// it is the 7th pin from the bottom right end of the SAM3X

// Output on port C 27 is high impedance for
// 1 second, followed by 5 short HIGH/LOW pulses

// Output on Port C 26 (to the left of C27) is HIGH whilst C27 is Hi-Z
// and Hi-Z whilst C27 is blinking

// Output on Port C 28 (to the right of C27) is HIGH for 0.5 sec then
// LOW for 0.5 sec whilst C27 is Hi-Z, and Hi-Z whilst C27 is blinking

// Using this you can tell if you have the right pin, and if you are
// accidentally touching one of the adjacent pins.

void setup() {                
}

void loop() {
 pinMode(3,OUTPUT);    
 pinMode(4,OUTPUT);

 PIOC->PIO_PER = 1<<27;  
 PIOC->PIO_ODR = 1<<27;
 digitalWrite(3, HIGH);  
 digitalWrite(4, HIGH);  
 delay(500);            
 digitalWrite(3, LOW);  
 delay(500);            
 digitalWrite(4, LOW);  
 pinMode(3,INPUT);    
 pinMode(4,INPUT);
 PIOC->PIO_OER = 1<<27;
 for(int i=0;i<5;i++){
   PIOC->PIO_SODR = 1<<27;
   delay(100);
   PIOC->PIO_CODR = 1<<27;
   delay(100);
 }

}


A9 is the north side of the RX led and can be attached with an unmodified pigtail clip.
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: delsauce on Mar 08, 2013, 12:19 am

Thanks :) If you add the addresses to the library I'll check it with a SRAM.


New code posted up on github.  Now you can have all 16 data pins and 23 address pins if you wish.  Note that you can't have A5 and NRD since the pins are wired together.  You'll need to operate without NRD if using A5 or cut the trace on the bottom of the board that ties the two pins together.

https://github.com/delsauce/ArduinoDueParallel.git (https://github.com/delsauce/ArduinoDueParallel.git)
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: stimmer on Mar 08, 2013, 01:56 am
Brilliant work - after setting some conservative timings it worked first time  :smiley-mr-green:

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)

Code: [Select]
#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");
}

Code: [Select]
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
Code: [Select]
 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 :)
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: graynomad on Mar 08, 2013, 02:42 am
Really nice stuff.

So for the sake of breaking out 2 pins this could have been an easy add on. Is that the case?

______
Rob
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: stimmer on Mar 08, 2013, 04:44 am
It would have been easier, yes, although I'd like to have had the other 2 data bus pins too (if I had to choose between the two I'd pick the data bus pins)

I'm not sure how worthwhile a memory expansion would be commercially, given that there's already quite a lot of ram in the Due, and there's always the Raspberry Pi for applications needing huge of memory. But it's an interesting enough project if you've already got an old SRAM chip ;)
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: delsauce on Mar 08, 2013, 11:12 pm


One last request: a getAddr() method :)



This is so that you can access the memory mapped peripheral directly without incurring the overhead of read/write?  If so, that seems like a reasonable request.  I realize that the current code isn't as efficient as it could be because I opted for simplicity.  Perhaps there is a better way I could have implemented it that would achieve both.  I'll noodle on that.

In the meantime, you can grab the new code with getAddress() on github
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: stimmer on Mar 08, 2013, 11:49 pm
It's more so I can use memset/memcpy/memmove and test if my circuit is reliable at full speed.

You can make the read and write methods faster by moving the code inside the class definition in the .h file, then the compiler will automatically inline them, removing the overhead.

Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: fablagrenouille on Mar 13, 2013, 10:11 am
Hello, Could somebody help me with a parallel data problem ?
I'm building a robot with two quadrature encoders for feed back control with an Arduino DUE. I need to read 8 bit parallel data values coming from the two Quadrature Decoder/ Counter Interface IC HCTL 2022 (from one of the two at a time of course). I've chosen the Arduino DUE's processor's pins PC12 to PC19 for my data bits D0 to D7. I can manage for selecting the register I want to read in one of the two ICs but could you give me the few lines of code needed for setting up my 8 bits data bus in the setup() and in the loop() for reading the values with the fastest method and form a byte from the reading. I don't need to send values on the 8 bit data bus,I only need to read incoming values.
Thanks a lot for helping because I don't understand the code given in the previous posts.
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: LMI1 on Mar 13, 2013, 07:48 pm
Random thoughts about CPU speed and external bus speed. It will be very difficult to get an external memory to work at CPU speed 80MHz. It may help if every memory read or write takes several clock cycles, but is it a RISC cpu after that. Really fast CPUs use several tricks to get relatively slow external memory and high CPU clock frequency to match. But I understand those are not possible with this chip. 80MHz clock needs faster than 12ns =1/80MHz memory.

When I read the posts more carefully I noticed that there is a speed setting for external memories. Even slower. Perhaps the external memory is more useful with some data roms or IO.

About IO. Slower IO operations are usually ok, because there are less of those than memory operations. And relatively slow IO is often not a problem if I think about external devices.

By the way, if address and data had been multiplexed it would take less pins. 16 address/datapins muxed gives 65000 16bit IO ports. Enough?

To fablagrenouille:
I think quadrature encoders are not so fast you need this kind of buses. Register/port reading and writing is easy and forums are full of instructions of how it is done.
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: stimmer on Mar 14, 2013, 06:34 pm
Here is the result of my memcpy test:

Code: [Select]
#include <Parallel.h>

void setup() {
  Parallel.begin(PARALLEL_BUS_WIDTH_8, PARALLEL_CS_0, 17, false, true);
  Parallel.setCycleTiming(4,4);
  Parallel.setPulseTiming(3,3,4,3);
  Parallel.setAddressSetupTiming(0,0,0,0);
  Serial.begin(115200);
}

uint8_t inb[8192],outb[8192];

void loop() {

  int r=micros();
  memcpy(inb,outb,8192);
  int s=micros();
 
  for(int a=0;a<8192;a++){inb[a]=random(256);outb[a]=random(256);}
  uint8_t *m=(uint8_t *)Parallel.getAddress();
 
  int t=micros();
  memcpy(m,inb,8192);
  int u=micros();
  memcpy(m+32768,m,8192);
  int v=micros();
  memcpy(outb,m+32768,8192);
  int w=micros();

  for(int a=0;a<8192;a++)if(inb[a]!=outb[a]){ Serial.println("Error ");break;}
 
  Serial.println("memcpy speed in MiB/s");
  Serial.print("int to int "); Serial.println(7812.5/(s-r)); // 7812.5==8192*1000000/1048576
  Serial.print("int to ext "); Serial.println(7812.5/(u-t));
  Serial.print("ext to ext "); Serial.println(7812.5/(v-u));
  Serial.print("ext to int "); Serial.println(7812.5/(w-v));
  Serial.println();
 
  delay(1000);
}

Code: [Select]
memcpy speed in MiB/s
int to int 76.59
int to ext 19.88
ext to ext 8.63
ext to int 13.40


That was the fastest timings I could get from the 55ns SRAM chip without errors - the 19.88MiB/s write speed is slightly out of spec 8)
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: fablagrenouille on Mar 15, 2013, 09:42 am
Thanks LMI for your answer.
Through the 8bit bus I have to read four bytes in each IC HCTL2022 and I don't want my program to loose to much time for this.
:smiley-roll-blue:
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: DanShephertan on Mar 24, 2013, 01:44 am
Hello guys.
Long time reader first time poster.

Im designing my own board for another purpose using the same ATSAM3X chip, and after reading this thread I am still a little confused as to how to setup External ram as a continuation of the internal ram - presumable this is possible.

What I mean by this, assuming that all the control, data and address lines are connected correctly to an external chip, how does the MCU know to point the stack to this external memory once all of the internal 48Kb internal ram is used ? is it automatic after setting some SMC control bit in some register?

If this is not possible, then it requires some memory management in code which is quite annoying. Any help would be appreciated.
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: graynomad on Mar 24, 2013, 03:40 am
Why do you want the stack to be in external RAM?

Quote
once all of the internal 48Kb internal ram is used ?

This will never all be used by the stack unless you have a massively-recursive function (very unlikely), and if data is that large put it in external.

So far I don't understand what you want to do.
______
Rob
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: bobcousins on Mar 24, 2013, 01:24 pm

Hello guys.
Long time reader first time poster.

Im designing my own board for another purpose using the same ATSAM3X chip, and after reading this thread I am still a little confused as to how to setup External ram as a continuation of the internal ram - presumable this is possible.

What I mean by this, assuming that all the control, data and address lines are connected correctly to an external chip, how does the MCU know to point the stack to this external memory once all of the internal 48Kb internal ram is used ? is it automatic after setting some SMC control bit in some register?

If this is not possible, then it requires some memory management in code which is quite annoying. Any help would be appreciated.


Fair question. The external memory appears to the MCU as a block of memory at an address depending on its Chip Select line. (These pins are labelled NCS0-NCS7 on the SAM3X). Typically you would connect CSx to the CS pin on your memory device. The lowest 24 bits of a memory address are decoded by the external memory device, the upper 8 bits are decoded in the memory controller. The locations of the memory sections are shown in Figure 8-1 of the SAM3X User Manual. For example, CS0 maps to 0x60000000.

The second question is how to map the application code to memory regions. This can be done very simply by direct access and setup from the application code, but this method is less flexible. You can allocate dynamic variables at runtime just by setting their address to a hardcoded value correspodning to the external memory. If you want to get automatic placement of variables, then you would need to use the linker.

By changing the linker file, you can specify the additional memory region, and what should go into it. At runtime, RAM variables will be zeroed or initialised with data copied from Flash as necessary. This is part of the Standard C initialisation procedure. With GCC toolchain you may need to edit a startup file to include the additional memory regions.

Note that you will need to edit the startup code to setup the memory controller before letting the code does its memory copying/zeroing. If you put the stack into external memory, you must make sure your startup code does not use it before it is setup! It is probably best to set a temporary stack in internal RAM for the startup code, and then change stack after the external memory is setup. It is simpler though to keep stack in internal memory, and use the external memory for other stuff.

The third question is how to get the application to use the extended memory. This can be done in the linker file, using combination of "pragma section" and the linker file, or explicitly in the application, depending on taste.

If this all seems quite complicated, then you are probably right. It needs good knowledge of the MCU and the toolchain to set the right things at the right point. Once setup, it becomes fairly seamless, but get one tiny thing wrong and it falls over in a heap.

To keep it simple, I would probably use direct setup from the application, and use the external memory as a pool of dynamic buffers for bulk data.
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: DanShephertan on Mar 26, 2013, 12:37 am
This has been very helpful thanks. I will not be this ambitious and stick to directly pushing objects into external ram instead.

I have one other related question. Can the due be programmed directly from USB or does it need the JTAG? I understand it cannot use the ISP like the Mega, but I really dislike those large JTAG connectors and I dont really have the real estate either. Suggestsions?
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: graynomad on Mar 26, 2013, 12:54 am
AFAIK there are 4 options for programming a SAM3X

USB bootloader (built in)
UART bootloader (built in and what the Due uses)
JTAG (10-way header but .05" spacing so pretty small)
SWD (4-way header, normal .1" spacing)

So you can load programs directly from USB but right now I can't find a description of exactly how you do that.

______
Rob
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: graynomad on Apr 04, 2013, 05:09 am
Quote
memcpy speed in MiB/s
int to int 76.59
int to ext 19.88
ext to ext 8.63
ext to int 13.40


@stimmer
From what I see in the data sheet it takes 6 cycles (Figure 27-7) to perform an X memory access, 84MHz / 6 = a transfer rate of 14MB/s and yet you get nearly 20.

Can you explain how this happens? Maybe there are savings in setup and hold times for a block move or something.

EDIT: OK I see in a later diagrams accesses down to 3 cycles with 0 setup and hold times, that would be 28MB/s so I guess anywhere between 14 and 28MB/s is fair game depending on various factors.

______
Rob

Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: krikus on Jul 18, 2013, 12:01 pm
Hello world. :)
I have a question about ext/SRAM. Can I connect two SRAM ic's (8bit) to external memory bus?
Use a full 16bit data bus and 17bit address bus for two ic's. I have two CY7C1019DV33 (128kx8bit) http://www.cypress.com/?docID=31943.
I know that some pins is not connected, I can connect them directly from sam3x ic. But how about NRD pin? Is it possible to do without it? (connect OE to ground as @stimmer did it)

PS: Sorry if my English is bad.
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: ralphnev on Jul 18, 2013, 05:53 pm
interesting project & will experiment with it in the next few days

I have in mind a large fifo  32Meg'ish (fpga tied to a sdram)
using no addresses - just reads & writes (need the PWM lines for other aspects of my programs) 
accounting can be taken care of by the Due
It would need a NWE/NRD/NBSx line

This is all to be rid of SDcard latency - i have too much data throughput  to deal with 100-300ms delay 
hmmmmm...
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: cnkz on Feb 07, 2014, 09:37 pm
Hi,

i am using this parallel library to drive a LCD display. I am using one address line to toggle the RS line of the display.

Unfortunately i do not get the first five address lines to work. The first address line that is working as expected is line A5. A0-A4 stay constantly high.

So my display works fine if i use line A5 (and 5-times faster than using ports), thanks for the work!

But i would like to use A0 (pin 9) instead of A5. Any idea how i can get A0 working? Any trick how to enable A0/C.21/PWM9?
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: delsauce on Feb 07, 2014, 09:51 pm
Did you look at the example provided in the library (S1D13700_LCD)?  It is using one address bit to communicate with an external parallel LCD...  I haven't tested that in a while, but it was working when I posted the code.  If not, then perhaps something has changed in the Arduino config since then?


Hi,

i am using this parallel library to drive a LCD display. I am using one address line to toggle the RS line of the display.

Unfortunately i do not get the first five address lines to work. The first address line that is working as expected is line A5. A0-A4 stay constantly high.

So my display works fine if i use line A5 (and 5-times faster than using ports), thanks for the work!

But i would like to use A0 (pin 9) instead of A5. Any idea how i can get A0 working? Any trick how to enable A0/C.21/PWM9?
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: cnkz on Feb 09, 2014, 01:18 pm
Yes, i used the LCD example as the foundation of my code. With that example code A0 wasn't working also. Seems something has changed...
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: LMI1 on Feb 14, 2014, 03:37 pm
About unusable pins. You can still use external memory if some address or datapins are not available.  If address pin is missing, you just can't use the whole memory space. With missing data pins it is similar.

So we'll have like a 256k 14bit ram or something available, instead of a full 1M 16bit device. But ofcourse cpu with a proper external bus would be nice.
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: graynomad on Feb 15, 2014, 11:39 pm
If address pins are missing you will have holes in the space that would cause duplications on top of other data.

So for example if A4 was missing you could write 16 contiguous bytes ok, but the 17th byte will go into location 0, thus overwriting the first byte. This could be manageable but a right PITA.

Likewise with data, the top bits may not matter if you stick to values below the first missing bit, but if you are missing any low-order bits you will be in trouble. This is almost not possible to use unless you "adjust" every variable you save and "unadjust" every variable you retrieve.

______
Rob
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: stimmer on Feb 16, 2014, 02:19 am
I just bought a DigiX (a Due clone, see https://www.kickstarter.com/projects/digistump/digix-the-ultimate-arduino-compatible-board-with-w and http://digistump.com/wiki/digix ). The DigiX has the four missing address and data pins (among others) on another row of connectors to the right of the board. Unfortunately, for compatibility with the Due the NRD signal is still wired to A5 so is unusable - although as I pointed out before you don't usually need it.

I wired up my 128Kx8bit ram up to the DigiX, and can confirm that the library works correctly with no modification needed, and no address gaps :) I haven't tried a 16 bit data bus yet as I haven't got a 16 bit ram, but I can't think of any reason why it wouldn't work.
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: graynomad on Feb 16, 2014, 03:22 am
How can there not be a gap and duplication with A5 missing? Or is it me that's missing (something :))

If you write 0-255 sequentially into the first 255 locations do you read 0-255 back?

_____
Rob
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: stimmer on Feb 16, 2014, 04:54 am
I worded it confusingly - what I meant was NRD is unusable, not A5. With them both wired to the same Due pin it's either one or the other. But NRD is not needed for a RAM.

My test program writes all 128K sequentially with a pseudorandom sequence then reads it all back checking every value - no errors :)
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: graynomad on Feb 16, 2014, 04:58 am
Yeah ok, that makes sense.

______
Rob
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: LMI1 on Feb 18, 2014, 10:58 pm

If address pins are missing you will have holes in the space that would cause duplications on top of other data.

So for example if A4 was missing you could write 16 contiguous bytes ok, but the 17th byte will go into location 0, thus overwriting the first byte. This could be manageable but a right PITA.

Likewise with data, the top bits may not matter if you stick to values below the first missing bit, but if you are missing any low-order bits you will be in trouble. This is almost not possible to use unless you "adjust" every variable you save and "unadjust" every variable you retrieve.

______
Rob


I don't think missing address pins cause other problems than a smaller device. For instance a 65000 byte device with 16 address bits. If leave one address pin/bit out, you'll have a device with 32000 usable bytes. If it is a some kind of rom and you connect it to a processor with all address pins, then you'll get gaps (or a great mess, if don't take care). I am not going to draw any truth tables so I leave this here.
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: pito on Apr 02, 2014, 10:39 am
You may connect the 8MB ramdisk to your DUE via the External Memory Bus (Static 8bit memory) - http://forum.arduino.cc/index.php?topic=220918.0
Code: [Select]
RDisk DUE (EMB signal names)
================
D0-D7 D0-D7
NWR NWE
NRD NRD
NDATA Ax

With Ax = 1 you write the 24bit starting address of a block
With Ax = 0 you write/read the bytes sequentially from the address



Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: pito on May 19, 2014, 01:00 pm
There is an undocumented feature in the driver with
Code: [Select]
PARALLEL_CS_NONE parameter
It causes 12ns timing for NRD/NWE regardless any other timing settings (verified with LA).

Also I do not understand the elapsed time results for the test sketch, where I write/read 1 mil bytes with the same elapsed time for quite different EMB timings:
Code: [Select]
// Configure parallel bus for 8bits, no CS, A0, and NRD and NWE
Parallel.begin(PARALLEL_BUS_WIDTH_8, PARALLEL_CS_1, 1, 1, 1);
// Configure bus timings.. EXPERIMENTAL
Parallel.setAddressSetupTiming(1,1,1,1);
// NWE, NCSWE, NRD, NCSRD  - we do not use NCSs
Parallel.setPulseTiming(4,1,7,1);
Parallel.setCycleTiming(6,9);

START OF THE TEST
WRITING BYTES TO RAMDISK
READING BYTES FROM RAMDISK
SUM = 234000000
ELAPSED WRITE = 680 msec
ELAPSED READ = 846 msec
TEST STOP

// Configure parallel bus for 8bits, no CS, A0, and NRD and NWE
Parallel.begin(PARALLEL_BUS_WIDTH_8, PARALLEL_CS_1, 1, 1, 1);
// Configure bus timings.. EXPERIMENTAL
Parallel.setAddressSetupTiming(1,1,1,1);
// NWE, NCSWE, NRD, NCSRD  - we do not use NCSs
Parallel.setPulseTiming(7,1,7,1);
Parallel.setCycleTiming(9,9);

START OF THE TEST
WRITING BYTES TO RAMDISK
READING BYTES FROM RAMDISK
SUM = 234000000
ELAPSED WRITE = 680 msec
ELAPSED READ = 846 msec
TEST STOP


with the sketch from http://forum.arduino.cc/index.php?topic=220918.msg1718934#msg1718934
(you may run the sketch without the ramdisk attached).

PS: with 12ns+48ns+12ns=72ns write cycle I would expect faster write than above 680ns per byte. Does it mean the driver (inclusive the "for loop") creates a 610ns overhead??
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: pito on May 21, 2014, 11:39 am
Another issue I cope is the NWE timing does not react to NWE pulse setting properly.
Quote
Parallel.setPulseTiming(7,1,7,1);

For example doubling the setting (with adjusting the CycleTiming accordingly) does not change the total elapsed time for write. It seems the NRD setting works.
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: pito on May 22, 2014, 02:47 pm
I did a measurement of the actual NWE signal High/Low durations during the 1mil write "for loop" vs. the NWE timing parameters settings (the resolution of my LA is 5ns):
Code: [Select]
A, P, C L H L+H MBytes/sec
========================================================================
1, 2, 4 25 205 230 4.35
1, 4, 6 45 180 225 4.44
1, 8,10 95 135 230 4.35
1,16,18 185 40 225 4.44
1,32,34 380 25 405 2.47

where
A - NWE setAddressSetupTiming
P - NWE setPulseTiming
C - NWE setCycleTiming
L[ns] - NWE active low pulse (write pulse)
H[ns] - overhead of the for..loop


How to decipher that results?? Any hint?
Why the L+H is constant for P=2 or 4 or 8 or 16?
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: rcalix1 on Nov 30, 2014, 02:07 am
Hello,

I read your Parallel library this afternoon and think it is very close to what I need. I have an Arduino Due board and a PGA69-CM1K co-processor. I am using this chip to do machine learning work. I have connected the Due board to the CM1K and can perform my analysis. However, I am currently using I2C to send the data. This approach is very slow and it affects my performance. So, what I need to do now is to send the data in Parallel (16 bits preferably although 8 bits would do for now). Could you tell me if you think this is possible with the library that you have. I noticed that some aspects appear to be very specific to the external memory device you are using. Any suggestions and advice on this would be greatly appreciated.

The spec of the chip I am using is here:http://www.cognimem.com/_docs/Technical-Manuals/TM_CM1K_PGA69_Hardware_Manual.pdf


Also, I tried compiling the library but it gave me an error that it could not find the "sam.h" file.

Thanks
Ricardo
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: EvIl_DeViL on May 26, 2015, 03:13 pm
what about taijiuino R3 (http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=72_73&products_id=2257&zenid=59b613evh5igc0jov9qa8sac11)?

I saw here (https://github.com/delsauce/ArduinoDueParallel/blob/master/Parallel.cpp) you're complaining about
D8 PC10
D9 PC11
A6 PC27
which are all broken out on taijiuino with many other pins as you can see in my previous link.

The only issue is PC26 (PWM4) which is still wired to PA29. It seems because they're trying to keep compatibility with mega shields as MarkT says here (http://forum.arduino.cc/index.php?topic=205569.msg1513220#msg1513220)

would a taijiuino be enough to drive a SDRAM like this (http://www.digikey.it/product-detail/en/AS4C32M16SM-7TCN/1450-1124-ND/4965488)?
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: MANIBMT on Aug 07, 2017, 01:11 pm
HI ,

I need LCD library for Arduino due.i don't where i get it.Any one can help me .
Title: Re: Parallel library for Due External Memory Bus/Static Memory Controller
Post by: jlsilicon on May 14, 2018, 03:28 pm
I didn't use NRD, I just tied the OE pin low (a write cycle still works with OE low - OE is active low)
- Makes sense to just tie the OE as High.

But, A6 is ignored / dropped out.
- Maybe (A6  PC27  N/C) can be soldered Manually Hotwired onto the Chip ?

I did not see any suggested RAM Chips.  The Chip need to be 3V - correct ?

Does anyone have a Diagram for this wiring ?