Example: Write / Read to IPS6404 PSRAM (8 MB)

Post your cool example code here.
User avatar
Pito
Posts: 27
Joined: Thu Mar 07, 2019 6:48 pm
Location: Rapa Nui
OS: Win7
IDE: Arduino, Sloeber, Uecide
Core: Roger
Board: Blue_Black_MM_103xx_407xx

Re: Example: Write / Read to IPS6404 PSRAM (8 MB)

Post by Pito » Mon Jan 13, 2020 7:42 pm

ag123 wrote:
Mon Jan 13, 2020 2:13 pm
4 MB per secs ! what is somewhat surprising is that /CS is held low for 2ms for the whole transfer and there is no data loss !
i added a simple xor checksum and verified that the written and read data match !
There is a dram inside - it is known the drams can carry information much longer than the typical refresh interval (ie 8-64us based on type). I've seen reports decades back drams kept info from seconds to minutes without being refreshed.

Anyhow, the 8us for /CE max duration is a crazy limitation. Working at 125degC I would rather split the writing/reading of a larger buffer into smaller chunks thus keeping /CE max 8us long ..

BTW, it is a Quad SPI memory - you may write 4x times faster, when lucky :)
Pukao Hats Cleaning Services, Ltd.

ag123
Posts: 243
Joined: Thu Mar 07, 2019 6:15 am
OS: linux
IDE: eclipse, arduino 1.8.5
Core: Roger's
Board: Maple mini, Bluepill

Re: Example: Write / Read to IPS6404 PSRAM (8 MB)

Post by ag123 » Tue Jan 14, 2020 6:23 am

unfortunately on the blackpill F401 it is wired for SPI, i'd make do with that for now :)
next thing is to try overclock again for 96 Mhz and 108 Mhz, that would give me 48 Mhz and 54 Mhz on SPI
it is actually the speeds that i wished to get. at those speeds i may be able to observe usb full speeds communications on SPI
but i'd think to try to stream that into the psram, i'd have throughput problems

it seemed drams does that typical RC decline, so i'd guess it is kind of lucky for 2ms the voltages are still high enough to keep it from tripping to zero, but if you look at Vassilis's post it is 13ms on stm32f103 and it seemed it still keeps memory !

If i can get 133 Mhz on spi, i'd be able to stream at the 'fast' settings of the psram, that is if only :lol:
but i'd guess to use that 'fast' mode, it is quite likely that built-in dram refresh would be turned off and that 8 us /CS limits would be highly critical
apparently, as 84 Mhz / 2 is actually 42 Mhz on stm32f401 spi, it is already beyond the specs allowed for the (normal) read command (03) 33 Mhz
http://platform.digiic.com/Docs/Product ... RAM%20.pdf
so it seem the (normal) read still have the refresh enabled but is limited to 33 Mhz ( but that still gives about 4 MBps (i.e. 8bits x 4 mbps)
it seemed i'm probably operating out of specs, and it so happen to work only because the frame overlaps the sampling interval at 42 mhz
or maybe otherwise, i've succeeded in overclocking the psram as well :lol:

User avatar
Pito
Posts: 27
Joined: Thu Mar 07, 2019 6:48 pm
Location: Rapa Nui
OS: Win7
IDE: Arduino, Sloeber, Uecide
Core: Roger
Board: Blue_Black_MM_103xx_407xx

Re: Example: Write / Read to IPS6404 PSRAM (8 MB)

Post by Pito » Tue Jan 14, 2020 9:10 am

While /CS is low it does not do any refresh, imho. Therefore the 8us limitation.
So it is a matter of luck whether it will work with XX ms without refresh.
Especially for higher temperatures, when the Leyden jars inside lose their charge faster :)

You may do an experiment - write FFs everywhere (or 00s) and then read back and compare periodically the data while keeping /CS low, and do measure time when you will start to get errors. My bet is 2 seconds at 25C :)

Anyhow, it seems the driver needs to consider the 8us to be on the safe side at the entire datasheet range of Vcc and Temp.
Pukao Hats Cleaning Services, Ltd.

ag123
Posts: 243
Joined: Thu Mar 07, 2019 6:15 am
OS: linux
IDE: eclipse, arduino 1.8.5
Core: Roger's
Board: Maple mini, Bluepill

Re: Example: Write / Read to IPS6404 PSRAM (8 MB)

Post by ag123 » Tue Jan 14, 2020 10:57 am

i think you are likely right, after all this test is just 8 kB out of that 8 MB,
maybe i'd make a bigger test, i'd try that 2s test as well :)
but that say we are streaming from an adc + dma, one way is to alternate the buffers.
e.g. for dma half transfers, transfer the first half when that interrupt flags, then when dma complete flags, send the 2nd half.
so hopefully between the 2 transfers would allow for an interleaving /CS high period for the dram refresh to complete
one doubt though is can we have both spi1 + adc on dma, i've not checked the specs but it would be a pity if only one of them can do dma.
this would not be feasible
it is kind of 'lucky' that this is an mcu with (quite a bit of) memory (64k on f401ccu), so if both dma can work it may be possible to funnel between say the adc and psram
the other way though is let the adc run on dma and we 'bit bang' the spi psram one byte at a time, after all we are aided by ART accelerator
oh oops, looks like adc1 and spi1 conflicts for dma, i'd guess i'd patch some wires from spi1 pins to the spi3 pins :lol:

ag123
Posts: 243
Joined: Thu Mar 07, 2019 6:15 am
OS: linux
IDE: eclipse, arduino 1.8.5
Core: Roger's
Board: Maple mini, Bluepill

Re: Example: Write / Read to IPS6404 PSRAM (8 MB)

Post by ag123 » Wed Jan 15, 2020 5:52 am

i did a slighly bigger test this time i used random numbers and used a 54k buffer, there is 64k sram in f401, i leave a little room to prevent crashes :P
this time round i used random numbers

Code: Select all

/**
 *
 * IPS6404 8 MB PSRAM (SPI SRAM) Write/Read example
 *
 * (c) 2019 by Vassilis Serasidis <avrsite@yahoo.gr>
 *   Home: https://www.serasidis.gr
 *  Forum: https://mcu.selfip.com , https://www.stm32duino.com
 *
 * Target: STM32F103C8 (Bluepill) at 72 MHz
 *   Core: STM official (https://github.com/stm32duino/Arduino_Core_STM32)
 *    IDE: Arduino 1.8.9
 */
#include <Arduino.h>
#include <usb_serial.h>
#include "SPI.h"

#define PSRAM_CS  	PA4
//#define BUFFER_LENGTH	8192
#define BUFFER_LENGTH	55296
#define WRITE_TO_PSRAM	0x02
#define READ_FROM_PSRAM	0x03

uint32_t tmr;
uint8_t tmp_buffer[BUFFER_LENGTH];
uint8_t led = 0;

uint32_t rstate;

uint8_t psram_read_id();
void psram_reset();
void psram_data(uint8_t cmd, uint32_t address, uint8_t *buf, uint32_t len);
void blinks();
void chkcmd();


/***************************************************
 *
 **************************************************/
void setup() {
  //SerialUSB.begin(0);
  Serial.begin();
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  pinMode(PSRAM_CS, OUTPUT);
  digitalWrite(PSRAM_CS, HIGH);

  //Serial.begin(9600);
  SPI.begin();
  SPI.beginTransaction(SPISettings(84000000, MSBFIRST, SPI_MODE0));
  chkcmd();
  Serial.println();
  blinks();

}


/***************************************************
 *
 **************************************************/

void loop() {
  uint32_t chksum, chksum1;

  Serial.println("get ID");
  psram_read_id();

  psram_reset();  //Reset the PSRAM chip

  /* Fill the temporary buffer with data */
  chksum =0;
  for(uint32_t i=0;i<BUFFER_LENGTH;i++){
    tmp_buffer[i] = rand();
    chksum ^= tmp_buffer[i];
  }

  /* Write 8192 byte buffer to PSRAM */
  Serial.print("Writing ");
  Serial.print(BUFFER_LENGTH);
  Serial.print(" bytes   to PSRAM (");
  tmr = millis();
  psram_data(WRITE_TO_PSRAM, 0, tmp_buffer, BUFFER_LENGTH); //Write <tmp_buffer> to PSRAM
  tmr = (millis() - tmr);
  Serial.print(tmr);
  Serial.println(" ms)");
  Serial.print("chksum:");
  Serial.println(chksum);

  /* Clear temporary buffer */
  for(uint32_t i=0;i<BUFFER_LENGTH;i++){
    tmp_buffer[i] = 0xff;
  }

  /* Read 8192 bytes from PSRAM */
  Serial.print("Reading ");
  Serial.print(BUFFER_LENGTH);
  Serial.print(" bytes from PSRAM (");
  tmr = millis();
  psram_data(READ_FROM_PSRAM, 0, tmp_buffer, BUFFER_LENGTH); //Read data from PSRAM to <tmp_buffer>
  tmr = (millis() - tmr);
  Serial.print(tmr);
  Serial.println(" ms)");
  chksum1 = 0;
  for(int i=0; i<BUFFER_LENGTH;i++) {
	  chksum1 ^= tmp_buffer[i];
  }
  Serial.print("chksum:");
  Serial.println(chksum1);
  if(chksum == chksum1) Serial.println("match!");

  for(uint32_t i=0;i<BUFFER_LENGTH;i++){
    if((i%16) == 0){  //Change line every 16 bytes
      Serial.println();
    }

    if(tmp_buffer[i] < 0x10){ //Print an ASCII zero in case the value is lower than 0x10
      Serial.write('0');
    }
    Serial.print(tmp_buffer[i], HEX);
    Serial.write(' ');
    if(i>16*10) break;
  }

  Serial.println("\n\nComplete !\n\n");

  //delay(1000);
  chkcmd();
  blinks();

}

/***************************************************
 *
 **************************************************/
uint8_t psram_read_id(){

  uint8_t data;

  digitalWrite(PSRAM_CS, LOW);
  SPI.transfer(0x9F);

  Serial.print("ID: ");
  for(int i=0;i<6;i++){
    data = SPI.transfer(0xff);
    if(data < 0x10){
      Serial.write('0');
    }
    Serial.print(data, HEX);
    Serial.write(' ');
  }
  digitalWrite(PSRAM_CS, HIGH);
  Serial.println();
  return 0;
}


/***************************************************
 *
 **************************************************/
void psram_reset(){
  digitalWrite(PSRAM_CS, LOW);
  SPI.transfer(0x66);
  digitalWrite(PSRAM_CS, HIGH);

  digitalWrite(PSRAM_CS, LOW);
  SPI.transfer(0x99);
  digitalWrite(PSRAM_CS, HIGH);
}

/***************************************************
 * Read or Write <len> bytes from/to PSRAM
 **************************************************/
void psram_data(uint8_t cmd, uint32_t address, uint8_t *buf, uint32_t len){

  uint8_t data;

  digitalWrite(PSRAM_CS, LOW);
  SPI.transfer(cmd);

  SPI.transfer((uint8_t)((address >> 16) & 0xFF));  //Address [23:16]
  SPI.transfer((uint8_t)((address >> 8) & 0xFF));   //Address [15:8]
  SPI.transfer((uint8_t)(address & 0xFF));          //Address [7:0]
  SPI.transfer(buf, len);

  digitalWrite(PSRAM_CS, HIGH);
}

void blinks() {
	for(int8_t i=0; i<10; i++) {
		digitalWrite(LED_BUILTIN, led);
		led = (~led) & 1;
		delay(100);
	}
}

void chkcmd() {
	  while(1) {
		  if(Serial.available()) {
			  char c = Serial.read();
			  if( c == 'r')
				  break;
		  }
		  asm("wfi");
	  }
}
results

Code: Select all

get ID
ID: 00 00 00 0D 5D 50
Writing 55296 bytes   to PSRAM (18 ms)
chksum:221
Reading 55296 bytes from PSRAM (18 ms)
chksum:221
match!

9E 60 F3 05 1D D6 3E D4 81 F1 EB 27 FC E6 52 FC
24 53 9C B0 D6 F1 23 B4 39 53 2E 0A 65 CB BA BC
FD 4B CA 47 D4 67 55 AF 55 30 E0 35 29 12 77 58
D0 31 F1 95 D4 6A C7 E7 DD 2D A6 69 2E 3D CB E9
36 22 92 1A 24 50 66 93 49 4E E2 EA 5A A9 9C DB
23 9A F8 06 93 CD 06 52 25 A4 8F 1A 13 2B F3 CE
83 60 FD 42 50 9C 29 58 61 38 AC BB 34 9B C0 D5
00 29 DA A3 B1 B7 88 7D 52 2B 38 C7 70 5E F1 08
F3 FF 06 2C E9 F7 6F 20 52 1B B2 E8 18 F1 CC 83
83 5D 20 74 AA 3F DE EC 1A BA 2A 86 54 68 9C AC
F0 0A

Complete !
this is one of the runs, many different runs produce a match on the checksum, including after reset
thus far none of them fail validation
this seem to suggest it is after all ok to use the psram in the 'slow' mode with big writes /CS low for quite a bit of ms
but i'd guess it is necessary to perform memory read or write ops during those ms rather than simply holding /CS low
that may have accidentally be a refresh operation on its own
interestingly, 54k / 18ms ~ 3 MB/s
this would suggest SPI is running at 24 Mhz within the 33 Mhz limits of psram specs

ag123
Posts: 243
Joined: Thu Mar 07, 2019 6:15 am
OS: linux
IDE: eclipse, arduino 1.8.5
Core: Roger's
Board: Maple mini, Bluepill

Re: Example: Write / Read to IPS6404 PSRAM (8 MB)

Post by ag123 » Wed Jan 15, 2020 6:31 am

next test the full 8 MB of the psram, writing 8KB blocks of random data
writing a full 8MB and later reading the 8MB

Code: Select all

/**
 *
 * IPS6404 8 MB PSRAM (SPI SRAM) Write/Read example
 *
 * (c) 2019 by Vassilis Serasidis <avrsite@yahoo.gr>
 *   Home: https://www.serasidis.gr
 *  Forum: https://mcu.selfip.com , https://www.stm32duino.com
 *
 * Target: STM32F103C8 (Bluepill) at 72 MHz
 *   Core: STM official (https://github.com/stm32duino/Arduino_Core_STM32)
 *    IDE: Arduino 1.8.9
 */
#include <Arduino.h>
#include <usb_serial.h>
#include "SPI.h"

#define PSRAM_CS  	PA4
#define BUFFER_LENGTH	8192
#define WRITE_TO_PSRAM	0x02
#define READ_FROM_PSRAM	0x03

uint32_t tmr, dur;
uint8_t tmp_buffer[BUFFER_LENGTH];
uint8_t led = 0;

uint32_t rstate;

uint8_t psram_read_id();
void psram_reset();
void psram_data(uint8_t cmd, uint32_t address, uint8_t *buf, uint32_t len);
void blinks();
void chkcmd();


/***************************************************
 *
 **************************************************/
void setup() {
  //SerialUSB.begin(0);
  Serial.begin();
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  pinMode(PSRAM_CS, OUTPUT);
  digitalWrite(PSRAM_CS, HIGH);

  //Serial.begin(9600);
  SPI.begin();
  SPI.beginTransaction(SPISettings(84000000, MSBFIRST, SPI_MODE0));
  chkcmd();
  Serial.println();
  blinks();

}


/***************************************************
 *
 **************************************************/

void loop() {
  uint32_t chksum, chksum1;

  Serial.println("get ID");
  psram_read_id();

  psram_reset();  //Reset the PSRAM chip

  /* Write 8192 byte buffer to PSRAM */
  Serial.print("Writing ");
  Serial.print(BUFFER_LENGTH);
  Serial.print(" bytes   to PSRAM (");

  dur = 0;
  chksum =0;
  /* Fill the temporary buffer with data */
  for(uint32_t a=0; a< 8*1024*1024; a+=BUFFER_LENGTH) {
	  for(uint32_t i=0;i<BUFFER_LENGTH;i++){
		  tmp_buffer[i] = rand();
		  chksum ^= tmp_buffer[i];
	  }
	  tmr = millis();
	  psram_data(WRITE_TO_PSRAM, a, tmp_buffer, BUFFER_LENGTH); //Write <tmp_buffer> to PSRAM
	  dur += (millis() - tmr);
  }

  Serial.print(dur);
  Serial.println(" ms)");
  Serial.print("chksum:");
  Serial.println(chksum);

  /* Read 8192 bytes from PSRAM */
  Serial.print("Reading ");
  Serial.print(BUFFER_LENGTH);
  Serial.print(" bytes from PSRAM (");
  dur = 0;
  chksum1 = 0;
  for(uint32_t a=0; a< 8*1024*1024; a+=BUFFER_LENGTH) {
    	/* Clear temporary buffer */
	  for(uint32_t i=0;i<BUFFER_LENGTH;i++){
		  tmp_buffer[i] = 0xff;
	  }
	  tmr = millis();
	  psram_data(READ_FROM_PSRAM, a, tmp_buffer, BUFFER_LENGTH); //Read data from PSRAM to <tmp_buffer>
	  dur += (millis() - tmr);
	  for(int i=0; i<BUFFER_LENGTH;i++) {
		  chksum1 ^= tmp_buffer[i];
	  }
  }
  Serial.print(dur);
  Serial.println(" ms)");
  Serial.print("chksum:");
  Serial.println(chksum1);
  if(chksum == chksum1) Serial.println("match!");

  for(uint32_t i=0;i<BUFFER_LENGTH;i++){
    if((i%16) == 0){  //Change line every 16 bytes
      Serial.println();
    }

    if(tmp_buffer[i] < 0x10){ //Print an ASCII zero in case the value is lower than 0x10
      Serial.write('0');
    }
    Serial.print(tmp_buffer[i], HEX);
    Serial.write(' ');
    if(i>16*10) break;
  }

  Serial.println("\n\nComplete !\n\n");

  //delay(1000);
  chkcmd();
  blinks();

}

/***************************************************
 *
 **************************************************/
uint8_t psram_read_id(){

  uint8_t data;

  digitalWrite(PSRAM_CS, LOW);
  SPI.transfer(0x9F);

  Serial.print("ID: ");
  for(int i=0;i<6;i++){
    data = SPI.transfer(0xff);
    if(data < 0x10){
      Serial.write('0');
    }
    Serial.print(data, HEX);
    Serial.write(' ');
  }
  digitalWrite(PSRAM_CS, HIGH);
  Serial.println();
  return 0;
}


/***************************************************
 *
 **************************************************/
void psram_reset(){
  digitalWrite(PSRAM_CS, LOW);
  SPI.transfer(0x66);
  digitalWrite(PSRAM_CS, HIGH);

  digitalWrite(PSRAM_CS, LOW);
  SPI.transfer(0x99);
  digitalWrite(PSRAM_CS, HIGH);
}

/***************************************************
 * Read or Write <len> bytes from/to PSRAM
 **************************************************/
void psram_data(uint8_t cmd, uint32_t address, uint8_t *buf, uint32_t len){

  uint8_t data;

  digitalWrite(PSRAM_CS, LOW);
  SPI.transfer(cmd);

  SPI.transfer((uint8_t)((address >> 16) & 0xFF));  //Address [23:16]
  SPI.transfer((uint8_t)((address >> 8) & 0xFF));   //Address [15:8]
  SPI.transfer((uint8_t)(address & 0xFF));          //Address [7:0]
  SPI.transfer(buf, len);

  digitalWrite(PSRAM_CS, HIGH);
}

void blinks() {
	for(int8_t i=0; i<10; i++) {
		digitalWrite(LED_BUILTIN, led);
		led = (~led) & 1;
		delay(100);
	}
}

void chkcmd() {
	  while(1) {
		  if(Serial.available()) {
			  char c = Serial.read();
			  if( c == 'r')
				  break;
		  }
		  asm("wfi");
	  }
}
results

Code: Select all

get ID
ID: 00 00 00 0D 5D 50
Writing 8192 bytes   to PSRAM (2703 ms)
chksum:170
Reading 8192 bytes from PSRAM (2696 ms)
chksum:170
match!

3D AA AF 29 2B 43 7B FC 47 A0 B8 FF 89 82 E9 85
4A 67 73 64 03 7D 68 D1 8C B7 85 9A 44 0E 02 E6
82 D6 C3 75 5E 40 F1 21 8E C6 12 8B D1 AA 52 A8
A0 03 DA 93 C0 83 A1 BF 0F 1D B2 CA 07 A6 19 DD
A1 3F CD 3C 8F 74 CE 21 93 79 43 5B 0A 3E 11 7B
2B 46 4D 2A 01 AA 85 B6 02 B6 0C F7 CF 36 E3 39
2E 31 69 65 FC DA 53 15 F7 B7 2C 43 12 62 F0 D1
A8 1A 5F 6C DD 01 C8 03 C1 89 8E AF B3 37 68 95
94 7B 7C 7F 30 10 DB 60 06 C1 6D E7 84 4F A2 68
0D 51 03 01 4C 0F 04 E9 1B 1D 67 EA 7C EE C9 0A
95 F7

Complete !


get ID
ID: 00 00 00 0D 5D 50
Writing 8192 bytes   to PSRAM (2698 ms)
chksum:30
Reading 8192 bytes from PSRAM (2718 ms)
chksum:30
match!

CA F4 30 0B 40 60 12 DC 35 66 12 DF BA FB 8C 5A
C0 57 3C 9E D7 DF 0E D8 6F 3E 14 4F 01 A7 5F 1E
79 23 2D 80 09 1E 7C 48 FF C8 2D 8C 31 9B 42 3B
B1 67 3C E7 5B 15 EB FC A6 50 B2 8F 23 26 74 C3
63 70 7F 51 31 F1 AE 6D E7 96 7F 5E F9 87 AE AC
36 FD A8 78 C2 4B D4 0A AB 75 DD AF A9 7E 9A AC
1B 26 C4 64 F5 D7 E8 67 8E D0 E9 28 F0 E2 9A 7F
0E 05 12 94 26 92 7C 4C DD B3 8F 38 AD 27 DC 77
0B 13 E0 48 DF 6D 85 98 40 B5 0A 8D B1 E7 B8 75
2E 50 70 E3 7B 70 7C 08 0A 94 F8 25 F4 66 5A 39
F7 13

Complete !


get ID
ID: 00 00 00 0D 5D 50
Writing 8192 bytes   to PSRAM (2695 ms)
chksum:93
Reading 8192 bytes from PSRAM (2710 ms)
chksum:93
match!

57 3E B1 ED 55 7E A9 BD 24 2B 6C BE EC 74 2F 30
36 46 05 D9 AC 41 B3 E0 53 C6 A3 03 BE 3F BD 56
70 71 97 8C B5 FB 08 6E 70 C9 48 8E 91 8C 31 CE
C2 CA 9E 3C F6 A6 35 3A 3C 83 B1 55 3E A7 CE A9
25 A1 32 66 D3 6F 8E BA 3B B3 BB 61 E8 CF 4A DC
42 B4 03 C7 84 ED 23 5D 54 34 AD 66 84 C7 51 20
08 1B 1F 63 EE D4 7D B9 25 E9 A5 0D CD 63 43 2E
74 EF C6 BC 6E 23 2F 95 F9 DE 8F C2 A6 17 50 58
83 AC 44 11 8F CA 2F D0 79 AA A7 34 DD 7F CE 81
4F 4E DC C4 AA D1 F5 27 F9 0A 8A 60 6C DE EA 69
5A 30

Complete !

8MB / 2.7s ~ 2.96 MB/s
it would seem the differences could be due to processor overheads rather than spi speeds

ag123
Posts: 243
Joined: Thu Mar 07, 2019 6:15 am
OS: linux
IDE: eclipse, arduino 1.8.5
Core: Roger's
Board: Maple mini, Bluepill

Re: Example: Write / Read to IPS6404 PSRAM (8 MB)

Post by ag123 » Wed Jan 15, 2020 8:08 am

next test update the codes a little to use DMA
8 MB test 8 kB blocks

Code: Select all

/***************************************************
 * Read or Write <len> bytes from/to PSRAM
 **************************************************/
void psram_data(uint8_t cmd, uint32_t address, uint8_t *buf, uint32_t len){

  uint8_t data;

  digitalWrite(PSRAM_CS, LOW);
  SPI.transfer(cmd);

  SPI.transfer((uint8_t)((address >> 16) & 0xFF));  //Address [23:16]
  SPI.transfer((uint8_t)((address >> 8) & 0xFF));   //Address [15:8]
  SPI.transfer((uint8_t)(address & 0xFF));          //Address [7:0]
  //SPI.transfer(buf, len);
  if(cmd == WRITE_TO_PSRAM)
	  SPI.dmaSend(buf, len, DMA_MINC_MODE);
  else
	  SPI.dmaTransfer((uint16_t) 0xFF, buf, len, 0);

  digitalWrite(PSRAM_CS, HIGH);
}
results

Code: Select all

get ID
ID: 00 00 00 0D 5D 50
Writing 8192 bytes   to PSRAM (1613 ms)
chksum:170
Reading 8192 bytes from PSRAM (1615 ms)
chksum:170
match!

3D AA AF 29 2B 43 7B FC 47 A0 B8 FF 89 82 E9 85
4A 67 73 64 03 7D 68 D1 8C B7 85 9A 44 0E 02 E6
82 D6 C3 75 5E 40 F1 21 8E C6 12 8B D1 AA 52 A8
A0 03 DA 93 C0 83 A1 BF 0F 1D B2 CA 07 A6 19 DD
A1 3F CD 3C 8F 74 CE 21 93 79 43 5B 0A 3E 11 7B
2B 46 4D 2A 01 AA 85 B6 02 B6 0C F7 CF 36 E3 39
2E 31 69 65 FC DA 53 15 F7 B7 2C 43 12 62 F0 D1
A8 1A 5F 6C DD 01 C8 03 C1 89 8E AF B3 37 68 95
94 7B 7C 7F 30 10 DB 60 06 C1 6D E7 84 4F A2 68
0D 51 03 01 4C 0F 04 E9 1B 1D 67 EA 7C EE C9 0A
95 F7

Complete !


get ID
ID: 00 00 00 0D 5D 50
Writing 8192 bytes   to PSRAM (1618 ms)
chksum:30
Reading 8192 bytes from PSRAM (1608 ms)
chksum:30
match!

CA F4 30 0B 40 60 12 DC 35 66 12 DF BA FB 8C 5A
C0 57 3C 9E D7 DF 0E D8 6F 3E 14 4F 01 A7 5F 1E
79 23 2D 80 09 1E 7C 48 FF C8 2D 8C 31 9B 42 3B
B1 67 3C E7 5B 15 EB FC A6 50 B2 8F 23 26 74 C3
63 70 7F 51 31 F1 AE 6D E7 96 7F 5E F9 87 AE AC
36 FD A8 78 C2 4B D4 0A AB 75 DD AF A9 7E 9A AC
1B 26 C4 64 F5 D7 E8 67 8E D0 E9 28 F0 E2 9A 7F
0E 05 12 94 26 92 7C 4C DD B3 8F 38 AD 27 DC 77
0B 13 E0 48 DF 6D 85 98 40 B5 0A 8D B1 E7 B8 75
2E 50 70 E3 7B 70 7C 08 0A 94 F8 25 F4 66 5A 39
F7 13

Complete !


get ID
ID: 00 00 00 0D 5D 50
Writing 8192 bytes   to PSRAM (1605 ms)
chksum:93
Reading 8192 bytes from PSRAM (1613 ms)
chksum:93
match!

57 3E B1 ED 55 7E A9 BD 24 2B 6C BE EC 74 2F 30
36 46 05 D9 AC 41 B3 E0 53 C6 A3 03 BE 3F BD 56
70 71 97 8C B5 FB 08 6E 70 C9 48 8E 91 8C 31 CE
C2 CA 9E 3C F6 A6 35 3A 3C 83 B1 55 3E A7 CE A9
25 A1 32 66 D3 6F 8E BA 3B B3 BB 61 E8 CF 4A DC
42 B4 03 C7 84 ED 23 5D 54 34 AD 66 84 C7 51 20
08 1B 1F 63 EE D4 7D B9 25 E9 A5 0D CD 63 43 2E
74 EF C6 BC 6E 23 2F 95 F9 DE 8F C2 A6 17 50 58
83 AC 44 11 8F CA 2F D0 79 AA A7 34 DD 7F CE 81
4F 4E DC C4 AA D1 F5 27 F9 0A 8A 60 6C DE EA 69
5A 30

Complete !
8 MB / 1.615s ~ 4.95 MB/s
:)

stevestrong
Posts: 87
Joined: Tue Mar 05, 2019 7:49 am
Location: Munich
OS: Win7 & 10
IDE: Arduino, Sloeber/Eclipse
Core: Libmaple
Board: Generic F103,F303,F401,F407,F411
Contact:

Re: Example: Write / Read to IPS6404 PSRAM (8 MB)

Post by stevestrong » Wed Jan 15, 2020 8:42 am

Which board and which CPU frequency did yo use?

ag123
Posts: 243
Joined: Thu Mar 07, 2019 6:15 am
OS: linux
IDE: eclipse, arduino 1.8.5
Core: Roger's
Board: Maple mini, Bluepill

Re: Example: Write / Read to IPS6404 PSRAM (8 MB)

Post by ag123 » Wed Jan 15, 2020 12:44 pm

blackpill F401CCU the recent one with the pads for spi flash below, spi psram is pin compatible.
running at stock speeds 84 mhz and hence spi is at 42 mhz (fcpu/2)
the psram i used i noted is from expressif, slightly pricier but looks of good quality
https://www.aliexpress.com/item/4000242457828.html
but accordingly they are after all from the same manufacturer if i guessed right
https://www.aliexpress.com/item/4000207056393.html
https://www.aliexpress.com/item/33028533291.html
https://www.aliexpress.com/item/4000218445956.html

if you review specs for ips6404
http://platform.digiic.com/Docs/Product ... RAM%20.pdf
vs expressif's they pretty much looked the same
https://www.espressif.com/sites/default ... eet_en.pdf

the pads for spi flash goes to SPI1, that one has a max speeds of 42 Mhz (84 Mhz / 2)
so if i'm comparing against specs for command 03 read - max 33 Mhz
it is kind of 'overclocked'
but there is another command 0b 'fast read' that apparently can goto 84 Mhz (or 100 Mhz 3.3v, 133 Mhz 1.8v)
i didn't try the 'fast' (0b) read command as apparently the 'slow' read (03) command works just ok as seen in the results here.
i'm not sure about the implications, but i'd ignore for now
i'd guess the 'fast' (0b) read command has more stringent requirements on max /CS low periods which according to specs is 8 us

a guess is that during that 'slow' read, the on chip refresh is probably running. it seemed at 42 mhz that'd be some form of 'overlap'.
but thus far, the results look just ok

stevestrong
Posts: 87
Joined: Tue Mar 05, 2019 7:49 am
Location: Munich
OS: Win7 & 10
IDE: Arduino, Sloeber/Eclipse
Core: Libmaple
Board: Generic F103,F303,F401,F407,F411
Contact:

Re: Example: Write / Read to IPS6404 PSRAM (8 MB)

Post by stevestrong » Wed Jan 15, 2020 2:05 pm

I just wonder why is there a big difference between with and w/o DMA, since I optimized quite a lot the non-DMA read and write routines.
I mean the USB and systick IRQs should not have such an influence.

Post Reply