Teensy 4.1 Beta Test

Good morning all.

I probably don't know the proper way to use this program now?

Here is a startup where I just did: s followed by R
Code:
C:\Users\kurte\Documents\Arduino\yyy\yyy.ino May 10 2020 07:59:05

Timing Data Logger  Compiled on May 10 2020 07:59:05

Initializing SD card...hardware initialized

ERAM ID: FF FF FF FF FF FF FF FF
at 0x 7000000
Wrong ID  :-(

Start PSRAM for LOGGING :: 
Twin buffers of size 294080 Bytes
Enter command selected from ( r, R{eRAM}, q, s, f )

SUCCESS:: working address ZERO at 0x70000000Starting logging

PSRAM eRAM _isr() logging

 	 BUFF at 70000000
 	 HIDE overWrap of 4294967295  <<<<< 
 	 HIDE firstWrap of 0  <<<<< 
	DONE 18379 >> 0, 0, 0, 0
0]  70.87 mSec fill [lp#5356625] 	Writing dbuff0 to data file.  tmilli =  1  took  13.42 mSec
 	 BUFF at 70090000
	DONE 18379 >> 0, 0, 0, 0
1]  57.86 mSec fill [lp#5] 	Writing dbuff1 to data file.  tmilli =  0  took  13.85 mSec
 	 BUFF at 70000000
	DONE 18379 >> 0, 0, 0, 0
0]  57.40 mSec fill [lp#5] 	Writing dbuff0 to data file.  tmilli =  1  took  13.81 mSec
 	 BUFF at 70090000
	DONE 18379 >> 0, 0, 0, 0
1]  57.48 mSec fill [lp#5] 	Writing dbuff1 to data file.  tmilli =  0  took  13.85 mSec
 	 BUFF at 70000000
	DONE 18379 >> 0, 0, 0, 0
0]  57.41 mSec fill [lp#5] 	Writing dbuff0 to data file.  tmilli =  1  took  13.83 mSec
 	 BUFF at 70090000
	DONE 18379 >> 0, 0, 0, 0
1]  57.45 mSec fill [lp#5] 	Writing dbuff1 to data file.  tmilli =  0  took  13.84 mSec
 	 BUFF at 70000000
	DONE 18379 >> 0, 0, 0, 0
...
 
@mjs513 - Running with your last code posted in #349.
Arduino 1.8.12 plus Beta 4... I am using I believe unmodified Beta 4, Teensy41_extram is I believe up to date.
 
@KurtE
Ok, something strange is going on I just copied and pasted it into a new sketch and its now its not working for me now. Try unpowering and reloading the sketch.

EDIT: I am wondering if some of that might be because with are not zeroing out the PSRAM in the sketch with eRAM.eraseDevice();
 
@KurtE - @defragster
Found the problem. Find the line with
Code:
eRAM.readArray(...
then delete" eRAM." so it just reads:
Code:
readArray(...
but the funny thing is that it seems it doesn't want to work unless you send a 'r' first then if you do an 'R' it works. Don't know.
 
Hi @mjs513 - Will try it again in a little bit. Just finishing putting on another layer of mulch on the Asparagus, and now off to mow the trails and the like, before it get too warm.
 
Quick catchup - just here - coffee ready. Glad I put that unconditional last line Struct print in there! With it being TOO sparse - there was no concept of what data it actually was seeing, and knew something was not right from the display speed diff.

There is something very ODD. r before R and diff behavior on fresh power versus - stuff was done first. Will get coffee and the newest posted code and give it a go.

The addressing issue for eRAM may fall out from Pauls' conceptualization and implementation of eMalloc(). I noted posts back the creation of the manual pointers was fraught with peril - or at least painful - with those blocks from eMalloc() direct addressing would be easier - and suppose the eRAM should feel/act the same - without having the magic offset from user.
 
@defragster - @KurtE
Here is an updated sketch Still has the same issue but now other skip errors are showing up:
Code:
/**************************************************************
  timing PSRAM datalogger for Teensy 4.1 with PSRAM - NO SD LOGGING - ONLY extRAM_t4.h required

  https://forum.pjrc.com/threads/60754-Teensy-3-6-SD-Card-missing-time-in-milliseconds?p=238352&viewfull=1#post238352
  Written for Teensy 3.6 by M. Borgerson  May 7, 2020
********************************************************************/

elapsedMicros logTime;
//#define USE_logtime
#define LOG_US (1000000 / SAMPLERATE)
#ifdef USE_logtime
#else
IntervalTimer ADCTimer;
#endif

struct datrec {
  uint32_t millitime;
  uint32_t microtime;
  uint32_t DWTCount;
  uint32_t byteswritten;
};

uint32_t logIndex = 0;
#define SAMPLERATE 20000
#define USE_PSRAM 1
#ifdef USE_PSRAM
#include <extRAM_t4.h>
extRAM_t4 eRAM;
#define BUFFSIZE  9190*2
//uint8_t config = 2; //0 - init eram only, 1-init flash only, 2-init both
//These have been replaced with defines for:
//INIT_PSRAM_ONLY
//INIT_FLASH_ONLY
//INIT_PSRM_FLASH
uint8_t config = INIT_PSRAM_ONLY;
// FAILS with 0x70050000 at offset 0x4000
struct datrec *dbuff0 = (datrec *)0x70050000;
struct datrec *dbuff1 = (datrec *)0x70090000;
uint32_t sbuff0_addr = 0x70050000;
uint32_t sbuff1_addr = 0x70090000;

//define a struct joining MYDATA_t to an array of bytes to be stored
uint32_t arraySize = sizeof(datrec);
typedef union MYDATA4RAM_t {
 datrec datastruct;
 uint8_t Packet[sizeof(datrec)];
};
MYDATA4RAM_t readdata; //data read from memory


#else  // THIS USES RAM1 and RAM2 buffer to show _isr() log works with same size buffers
#define BUFFSIZE  9190*2
struct datrec dbuff1[BUFFSIZE];
struct datrec *dbuff0 = (datrec *)malloc(BUFFSIZE*sizeof(datrec));
#endif


#define DEBUGPRINT true

int logging = 0;

char method = 0;

// these variables are declared volatile because they are changed or used in the
// interrupt handler
volatile uint16_t saveidx = 0;
volatile int16_t writebuffnum = -1;
volatile uint16_t savebuffnum = 0;
volatile uint32_t filestartmilli = 0;
volatile uint32_t byteswritten = 0;

const int ledpin = 13;

#define LEDON  digitalWriteFast(ledpin, HIGH);
#define LEDOFF digitalWriteFast(ledpin, LOW);

const char compileTime [] = "Timing Data Logger  Compiled on " __DATE__ " " __TIME__;
void setup() {
  if ( ARM_DWT_CYCCNT == ARM_DWT_CYCCNT ) {   // activate ARM cycle counter
    ARM_DEMCR |= ARM_DEMCR_TRCENA; // Assure Cycle Counter active
    ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
  }

  pinMode(ledpin, OUTPUT);
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial && millis() < 4000 );
  Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
  Serial.println(compileTime);
  // see if the card is present and can be initialized:
  Serial.print("Initializing SD card...");

#ifdef USE_PSRAM
  eRAM.begin(config);
  Serial.print("Start PSRAM for LOGGING :: ");
#else
  Serial.print("LOGGING from RAM :: ");
#endif

  Serial.printf("\nTwin buffers of size %u Bytes\n" , sizeof(datrec)*BUFFSIZE );
  Serial.println("Enter command selected from ( r, R{eRAM}, q, s, f )");
}

void FastBlink(void) {  // blink forever
  while (1) {
    LEDON
    delay(50);
    LEDOFF
    delay(50);
  }
}

static uint32_t elapsedUS = 0;
uint32_t loopCnt = 0, loopSpd;
elapsedMillis elapsedLoop = 0;
void loop() {
  // put your main code here, to run repeatedly:
  char ch;
  uint32_t microselapsed;
  elapsedMicros wrtelapsed = 0;
  loopCnt++;
  if ( elapsedLoop >= 1000 ) {
    loopSpd = loopCnt;
    loopCnt = 0;
    elapsedLoop -= 1000;
  }

#ifdef USE_logtime
  if ( logging && logTime > LOG_US ) {
    logTime -= LOG_US;
    if ( logging == 1 )
      ADCChore();
    esle if ( logging == 2 )
      ADCChore_eRAM();
  }
#endif

  if (Serial.available()) {
    ch = Serial.read();
    if (ch == 'r') {
      method = ch;
      StartLogging(1);
    }
    if (ch == 'R') {
#ifdef USE_PSRAM
      method = ch;
      StartLogging(2);
#endif
    }

    if (ch == 's') {
      StopLogging();
      Serial.print("SUCCESS:: working address ZERO at 0x70000000");
      dbuff0 = (datrec *)0x70000000;
      dbuff1 = (datrec *)0x70090000;
      sbuff0_addr = 0x70000000;
      sbuff1_addr = 0x70090000;
    }

    if (ch == 'f') {  // FAILS with 0x70050000 at offset 0x4000
      StopLogging();
      Serial.print("FAIL:: working address ZERO at 0x70050000");
      dbuff0 = (datrec *)0x70050000;
      dbuff1 = (datrec *)0x70090000;
      sbuff0_addr = 0x70050000;
      sbuff1_addr = 0x70090000;
    }

    if (ch == 'q') StopLogging();
  }
  // Now check to see if a buffer is ready to be written to SD
  // writebuffnum will be set in the interrupt handler
  if (writebuffnum == 0) { //is dbuff0 ready?
    LEDON
    writebuffnum = -1;
    if (1) { //if the file is open write dbuff0
      wrtelapsed = 0;
      WriteBinary(&dbuff0[0], BUFFSIZE);
      microselapsed = wrtelapsed;
      if (DEBUGPRINT) {
        loopCnt = loopCnt / (micros() - elapsedUS);
        Serial.printf("0] %6.2f mSec fill [lp#%lu] \t", (float)(micros() - elapsedUS) / 1000.0, loopSpd );
        Serial.print("Writing dbuff0 to data file.  tmilli = ");
        Serial.printf(" %lu  took %6.2f mSec\n", dbuff0[0].millitime, (float)microselapsed / 1000.0);
        elapsedUS = micros();
      }
    }
    LEDOFF
  }
  else if (writebuffnum == 1) { // is dbuff1 ready?
    LEDON
    writebuffnum = -1;
    if (1) { //if the file is open write dbuff0
      wrtelapsed = 0;
      WriteBinary(&dbuff1[0], BUFFSIZE);
      microselapsed = wrtelapsed;
      if (DEBUGPRINT) {
        loopCnt = loopCnt / (micros() - elapsedUS);
        Serial.printf("1] %6.2f mSec fill [lp#%lu] \t", (float)(micros() - elapsedUS) / 1000.0, loopSpd );
        Serial.print("Writing dbuff1 to data file.  tmilli = ");
        Serial.printf(" %lu  took %6.2f mSec\n", dbuff1[0].millitime, (float)(microselapsed) / 1000.0);
        elapsedUS = micros();
      }
    }
    LEDOFF
  }
  //delay(5);
}  // end of the loop() function

// write a buffer to the file as binary record. This  takes more time and file space than
// binary format, but can be directly read on PC.
// Note that we have to cast datrec pointer to a uint8_t pointer
// to keep the SD libraryhappy
static uint32_t firstWrap = 999;
static uint32_t overWrap = 999;
void WriteBinary(volatile struct datrec *drp, size_t numstructs) {

//  dataFile.write((uint8_t *)drp, numstructs * sizeof(datrec));

  Serial.printf(" \t BUFF at %lX\n", drp );
  uint32_t lastM = 0;
  uint32_t kk, lastB = 5;
  uint32_t ii = 0, iiL = 0;
  if(method == 'r'){
      lastB = drp[0].byteswritten;
      for ( kk = 0; kk < numstructs; kk++) {
        if ( lastM != drp[kk].millitime || lastB != drp[kk].byteswritten ) {
          if ( overWrap == 999 ) {
            overWrap = ii - 1;
            Serial.printf(" \t HIDE overWrap of %lu  <<<<< \n", overWrap );
          }
          else if ( firstWrap == 999 ) {
            firstWrap = ii;
            Serial.printf(" \t HIDE firstWrap of %lu  <<<<< \n", firstWrap );
          }
          if ( lastM != drp[kk].millitime )
            lastM = drp[kk].millitime;
    
          if ( ii != iiL && ii != firstWrap && ii != overWrap ) {
            Serial.printf("skipped %lu\t", ii);
            Serial.printf("%lu, %lu, %lX, %lu\t", drp[kk].millitime, drp[kk].microtime, drp[kk].DWTCount, drp[kk].byteswritten);
            Serial.printf(" \t kk==%lu  ????\n", kk );
          }
          iiL = ii;
          ii = 0;
        }
        else
          ii++;
      }
      kk = numstructs - 1;
      Serial.printf("\tDONE %lu >> %lu, %lu, %lX, %lu\n", kk, drp[kk].millitime, drp[kk].microtime, drp[kk].DWTCount, drp[kk].byteswritten);
    
      //dataFile.write((uint8_t *)drp, numstructs * sizeof(datrec));
  } else {
    uint32_t ramAddr = (uint32_t *) drp;
      uint32_t vmillitime = 0, vmicrotime = 0, vDWTCount = 0, vbyteswritten = 0;
      readArray(ramAddr, arraySize, readdata.Packet);
      lastB = readdata.datastruct.byteswritten;
      for ( kk = 0; kk < numstructs; kk++) {
        readArray(ramAddr+arraySize*kk, arraySize, readdata.Packet);
        vmillitime = readdata.datastruct.millitime;
        vmicrotime = readdata.datastruct.microtime;
        vDWTCount = readdata.datastruct.DWTCount;
        vbyteswritten = readdata.datastruct.byteswritten;
        if ( lastM != vmillitime || lastB != vbyteswritten ) {
          if ( overWrap == 999 ) {
            overWrap = ii - 1;
            Serial.printf(" \t HIDE overWrap of %lu  <<<<< \n", overWrap );
          }
          else if ( firstWrap == 999 ) {
            firstWrap = ii;
            Serial.printf(" \t HIDE firstWrap of %lu  <<<<< \n", firstWrap );
          }
          if ( lastM != vmillitime )
            lastM = vmillitime;
    
          if ( ii != iiL && ii != firstWrap && ii != overWrap ) {
            Serial.printf("skipped %lu\t", ii);
            Serial.printf("%lu, %lu, %lX, %lu\t", vmillitime, vmicrotime, vDWTCount, vbyteswritten);
            Serial.printf(" \t kk==%lu  ????\n", kk );
          }
          iiL = ii;
          ii = 0;
        }
        else
          ii++;
      }
      kk = numstructs - 1;
      Serial.printf("\tDONE %lu >> %lu, %lu, %lX, %lu\n", kk, vmillitime, vmicrotime, vDWTCount, vbyteswritten);
    
      //dataFile.write((uint8_t *)drp, numstructs * sizeof(datrec));
  }
}

void ADCChore_eRAM(void) { // eRAM function access
#ifdef USE_PSRAM // avoid eRAM non-def error on RAM only test
  uint32_t tmilli;
  tmilli = millis() - filestartmilli;
  byteswritten += sizeof(datrec); // update global bytes written count
  // save in  the proper buffer--defined by savebuffnum
  if (savebuffnum == 0) { // put data in dbuff0
    writeLong(sbuff0_addr + saveidx , tmilli);
    writeLong(sbuff0_addr + saveidx + 4, logIndex++);
    writeLong(sbuff0_addr + saveidx + 8, (uint32_t)sbuff0_addr + (sizeof(datrec) * saveidx));
    writeLong(sbuff0_addr + saveidx + 12, 0);
    saveidx += sizeof(datrec);
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      writebuffnum = 0;
      savebuffnum = 1;   // start saving in other buffer on next interrupt
      saveidx = 0;  // start at beginning of next buffer
    }
  } else {  // must be saving to dbuff1
    writeLong(sbuff1_addr + saveidx , tmilli);
    writeLong(sbuff1_addr + saveidx  + 4, logIndex++);
    writeLong(sbuff1_addr + saveidx  + 8, (uint32_t)sbuff1_addr + (sizeof(datrec) * saveidx));
    writeLong(sbuff1_addr + saveidx  + 12, 1);
    saveidx += sizeof(datrec);
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      writebuffnum = 1;
      savebuffnum = 0;   // start saving in other buffer on next interrupt
      saveidx = 0;   // start at beginning of next buffer
    }
  }
#endif
}

void ADCChore(void) { // DIRECT ACCESS
  uint32_t tmilli;
  tmilli = millis() - filestartmilli;
  byteswritten += sizeof(datrec); // update global bytes written count
  // save in  the proper buffer--defined by savebuffnum
  if (savebuffnum == 0) { // put data in dbuff0
    dbuff0[saveidx].millitime = tmilli;
    dbuff0[saveidx].microtime =  logIndex++;
    dbuff0[saveidx].DWTCount = (uint32_t)dbuff0 + (sizeof(datrec) * saveidx);;
    dbuff0[saveidx].byteswritten = 0;
    saveidx++;
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      writebuffnum = 0;
      savebuffnum = 1;   // start saving in other buffer on next interrupt
      saveidx = 0;  // start at beginning of next buffer
    }
  } else {  // must be saving to dbuff1
    dbuff1[saveidx].millitime = tmilli;
    dbuff1[saveidx].microtime =  logIndex++;
    dbuff1[saveidx].DWTCount = (uint32_t)dbuff1 + (sizeof(datrec) * saveidx);;
    //dbuff1[saveidx].byteswritten = byteswritten;
    dbuff1[saveidx].byteswritten = 1;
    saveidx++;
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      writebuffnum = 1;
      savebuffnum = 0;   // start saving in other buffer on next interrupt
      saveidx = 0;   // start at beginning of next buffer
    }
  }
}

void StartLogging(int logType) {
  // we open in a mode that creates a new file each time
  // instead of appending as in the Arduino example
  if ( logging ) return;
  logging = logType;
  elapsedUS = micros();
  loopCnt = 0;
  firstWrap = 999;
  overWrap = 999;
  logIndex = 0;

  Serial.println("Starting logging");

  // initialize some variables for the buffers
  saveidx = 0;   // start saving at beginning of buffer
  savebuffnum = 0;  // start saving in dbuff0
  writebuffnum = -1;  // indicates no buffer ready yet
  //  start the interval timer to begin logging
  filestartmilli = millis();
  byteswritten = 0;
#ifdef USE_logtime
  logTime = 0;
#else
  if ( logging == 1 ) {
    Serial.println("PSRAM DIRECT _isr() logging");
    ADCTimer.begin(ADCChore, 1000000 / SAMPLERATE); //begin() expects timer period in microseconds
  }
  else if ( logging == 2 ) {
    Serial.println("PSRAM eRAM _isr() logging");
    ADCTimer.begin(ADCChore_eRAM, 1000000 / SAMPLERATE); //begin() expects timer period in microseconds
  }
#endif

}

void StopLogging(void) {
  if ( 0 == logging ) return;
  Serial.println("Stopping logging");
  logging = 0;
#ifdef USE_logtime
  logTime = 0;
  if (DEBUGPRINT) Serial.println("eMicros Log halted");
#else
  ADCTimer.end();
  if (DEBUGPRINT) Serial.println("ADCTimer halted");
#endif
  delay(10);
  writebuffnum = -1;
  Serial.printf("%lu KBytes written to file.\n", byteswritten / 1024);
  // in the interest of simplicity, we ignore any partial buffer at the end
}

void readArray (uint32_t ramAddr, uint32_t length, uint8_t *data)
{
  uint32_t ii;
  uint8_t *ptrERAM = (uint8_t *)(ramAddr);

  //uint32_t timenow = micros();
  for ( ii = 0; ii < length; ii++ ) {
    data[ii] = ptrERAM[ii];
  }
  //Serial.printf("Read (us): %d\n", micros()-timenow);
  //Serial.printf("read @%06X: ", ramAddr);
  //for (uint32_t i=0; i < length; i++) Serial.printf(" %02X", *(((uint8_t *)data) + i));
  //Serial.printf("\n");
  //Serial.printf("rd @%08X: ", (uint32_t)ptrERAM);
  //for (uint32_t i=0; i < length; i++) Serial.printf(" %02X", ptrERAM[i]);
  //Serial.printf("\n");
}

void writeArray (uint32_t ramAddr, uint32_t items, uint8_t values[])
{ 
  uint32_t ii;
  uint8_t *ptrERAM = (uint8_t *)(ramAddr);
  
  //Serial.printf("write @%06X:\n", ramAddr);
  //for (uint32_t i=0; i < items; i++) Serial.printf(" %02X", *(((uint8_t *)values) + i));
  //Serial.printf("\n");
  //uint32_t timenow = micros();
  for ( ii = 0; ii < items; ii++ ) {
    ptrERAM[ii] = values[ii];
  }
  //Serial.printf("Write (us): %d\n", micros()-timenow);

}

void writeLong(uint32_t ramAddr, uint32_t value)
{
  uint8_t *buffer = reinterpret_cast<uint8_t *>(&value);
  writeArray(ramAddr, 4, buffer);
  
}

void readLong(uint32_t ramAddr, uint32_t *value)
{
  uint8_t buffer[4];
  readArray(ramAddr, 4, buffer);
  *value = *reinterpret_cast<uint32_t *>(buffer);

}

Code:
PSRAM eRAM _isr() logging

 	 BUFF at 70000000
 	 HIDE overWrap of 15  <<<<< 
skipped 16	1, 16, 70001000, 0	 	 kk==16  ????
 	 HIDE firstWrap of 19  <<<<< 
skipped 12	1896, 37909, 700047D0, 0	 	 kk==1149  ????
skipped 16	1897, 37926, 700048E0, 0	 	 kk==1166  ????
	DONE 18379 >> 2757, 55139, 70047CB0, 0
0]  65.48 mSec fill [lp#5356600] 	Writing dbuff0 to data file.  tmilli =  0  took   8.03 mSec
 	 BUFF at 70090000
skipped 6	58, 1156, 70090700, 1	 	 kk==7  ????
skipped 1	2815, 56289, 700947D0, 1	 	 kk==1149  ????
skipped 16	2816, 56306, 700948E0, 1	 	 kk==1166  ????
skipped 16	1666, 33323, 700CA5F0, 1	 	 kk==14943  ????
skipped 2	1667, 33326, 700CA620, 1	 	 kk==14946  ????
	DONE 18379 >> 1838, 36759, 700D7CB0, 1

Have to be missing something obvious but need a nap at this point.
 
Im back...

Made edit ...

Last run:
Code:
C:\Users\kurte\Documents\Arduino\yyy\yyy.ino May 10 2020 11:08:19

Timing Data Logger  Compiled on May 10 2020 11:08:19

Initializing SD card...hardware initialized

ERAM ID: FF FF FF FF FF FF FF FF
at 0x 7000000
Wrong ID  :-(

Start PSRAM for LOGGING :: 
Twin buffers of size 294080 Bytes
Enter command selected from ( r, R{eRAM}, q, s, f )

SUCCESS:: working address ZERO at 0x70000000FAIL:: working address ZERO at 0x70050000Starting logging

PSRAM DIRECT _isr() logging

 	 BUFF at 70050000
 	 HIDE overWrap of 9  <<<<< 
skipped 10	1, 10, 700500A0, 0	 	 kk==10  ????
 	 HIDE firstWrap of 19  <<<<< 
skipped 13	919, 18380, 70090000, 1	 	 kk==16384  ????
skipped 0	919, 18381, 70090010, 1	 	 kk==16385  ????
skipped 16	827, 16530, 70090920, 0	 	 kk==16530  ????
	DONE 18379 >> 919, 18379, 70097CB0, 0
0] 926.23 mSec fill [lp#4759584] 	Writing dbuff0 to data file.  tmilli =  0  took   7.22 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1] 919.18 mSec fill [lp#4759584] 	Writing dbuff1 to data file.  tmilli =  919  took   7.42 mSec
Stopping logging

ADCTimer halted

583 KBytes written to file.
Starting logging

PSRAM eRAM _isr() logging

 	 BUFF at 70050000
 	 HIDE overWrap of 4294967295  <<<<< 
 	 HIDE firstWrap of 0  <<<<< 
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  70.03 mSec fill [lp#5356625] 	Writing dbuff0 to data file.  tmilli =  0  took  12.57 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  57.45 mSec fill [lp#5356625] 	Writing dbuff1 to data file.  tmilli =  58  took  12.58 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.05 mSec fill [lp#5356625] 	Writing dbuff0 to data file.  tmilli =  115  took  13.20 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.85 mSec fill [lp#5356625] 	Writing dbuff1 to data file.  tmilli =  173  took  12.61 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.03 mSec fill [lp#5356625] 	Writing dbuff0 to data file.  tmilli =  230  took  13.20 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.84 mSec fill [lp#5356625] 	Writing dbuff1 to data file.  tmilli =  288  took  12.61 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.06 mSec fill [lp#5356625] 	Writing dbuff0 to data file.  tmilli =  345  took  13.23 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.82 mSec fill [lp#5356625] 	Writing dbuff1 to data file.  tmilli =  402  took  12.62 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.04 mSec fill [lp#5356625] 	Writing dbuff0 to data file.  tmilli =  460  took  13.22 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.86 mSec fill [lp#5356625] 	Writing dbuff1 to data file.  tmilli =  517  took  12.63 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.01 mSec fill [lp#5356625] 	Writing dbuff0 to data file.  tmilli =  575  took  13.21 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.81 mSec fill [lp#228822] 	Writing dbuff1 to data file.  tmilli =  632  took  12.59 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.01 mSec fill [lp#228822] 	Writing dbuff0 to data file.  tmilli =  690  took  13.16 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.87 mSec fill [lp#228822] 	Writing dbuff1 to data file.  tmilli =  747  took  12.60 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.01 mSec fill [lp#228822] 	Writing dbuff0 to data file.  tmilli =  805  took  13.17 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.86 mSec fill [lp#228822] 	Writing dbuff1 to data file.  tmilli =  862  took  12.59 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.04 mSec fill [lp#228822] 	Writing dbuff0 to data file.  tmilli =  919  took  13.20 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.84 mSec fill [lp#228822] 	Writing dbuff1 to data file.  tmilli =  977  took  12.60 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.03 mSec fill [lp#228822] 	Writing dbuff0 to data file.  tmilli =  1034  took  13.19 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.89 mSec fill [lp#228822] 	Writing dbuff1 to data file.  tmilli =  1092  took  12.64 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  57.96 mSec fill [lp#228822] 	Writing dbuff0 to data file.  tmilli =  1149  took  13.16 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.85 mSec fill [lp#228822] 	Writing dbuff1 to data file.  tmilli =  1207  took  12.57 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.08 mSec fill [lp#228822] 	Writing dbuff0 to data file.  tmilli =  1264  took  13.21 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.80 mSec fill [lp#228822] 	Writing dbuff1 to data file.  tmilli =  1322  took  12.57 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.06 mSec fill [lp#228822] 	Writing dbuff0 to data file.  tmilli =  1379  took  13.19 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.87 mSec fill [lp#228822] 	Writing dbuff1 to data file.  tmilli =  1437  took  12.62 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.01 mSec fill [lp#228822] 	Writing dbuff0 to data file.  tmilli =  1494  took  13.20 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.82 mSec fill [lp#228822] 	Writing dbuff1 to data file.  tmilli =  1551  took  12.58 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.03 mSec fill [lp#228822] 	Writing dbuff0 to data file.  tmilli =  1609  took  13.17 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.89 mSec fill [lp#47995] 	Writing dbuff1 to data file.  tmilli =  1666  took  12.62 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.02 mSec fill [lp#47995] 	Writing dbuff0 to data file.  tmilli =  1724  took  13.21 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.89 mSec fill [lp#47995] 	Writing dbuff1 to data file.  tmilli =  1781  took  12.67 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.04 mSec fill [lp#47995] 	Writing dbuff0 to data file.  tmilli =  1839  took  13.26 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.81 mSec fill [lp#47995] 	Writing dbuff1 to data file.  tmilli =  1896  took  12.64 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.04 mSec fill [lp#47995] 	Writing dbuff0 to data file.  tmilli =  1954  took  13.24 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.76 mSec fill [lp#47995] 	Writing dbuff1 to data file.  tmilli =  2011  took  12.56 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.13 mSec fill [lp#47995] 	Writing dbuff0 to data file.  tmilli =  2068  took  13.25 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.83 mSec fill [lp#47995] 	Writing dbuff1 to data file.  tmilli =  2126  took  12.65 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.04 mSec fill [lp#47995] 	Writing dbuff0 to data file.  tmilli =  2183  took  13.25 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.78 mSec fill [lp#47995] 	Writing dbuff1 to data file.  tmilli =  2241  took  12.60 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.00 mSec fill [lp#47995] 	Writing dbuff0 to data file.  tmilli =  2298  took  13.17 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.86 mSec fill [lp#47995] 	Writing dbuff1 to data file.  tmilli =  2356  took  12.59 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.07 mSec fill [lp#47995] 	Writing dbuff0 to data file.  tmilli =  2413  took  13.22 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.81 mSec fill [lp#47995] 	Writing dbuff1 to data file.  tmilli =  2471  took  12.59 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.08 mSec fill [lp#47995] 	Writing dbuff0 to data file.  tmilli =  2528  took  13.23 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.82 mSec fill [lp#47995] 	Writing dbuff1 to data file.  tmilli =  2586  took  12.62 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.05 mSec fill [lp#174908] 	Writing dbuff0 to data file.  tmilli =  2643  took  13.23 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.82 mSec fill [lp#174908] 	Writing dbuff1 to data file.  tmilli =  2700  took  12.62 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.03 mSec fill [lp#174908] 	Writing dbuff0 to data file.  tmilli =  2758  took  13.21 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.85 mSec fill [lp#174908] 	Writing dbuff1 to data file.  tmilli =  2815  took  12.62 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  57.97 mSec fill [lp#174908] 	Writing dbuff0 to data file.  tmilli =  2873  took  13.15 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.89 mSec fill [lp#174908] 	Writing dbuff1 to data file.  tmilli =  2930  took  12.61 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.00 mSec fill [lp#174908] 	Writing dbuff0 to data file.  tmilli =  2988  took  13.17 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.88 mSec fill [lp#174908] 	Writing dbuff1 to data file.  tmilli =  3045  took  12.61 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.06 mSec fill [lp#174908] 	Writing dbuff0 to data file.  tmilli =  3103  took  13.23 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.80 mSec fill [lp#174908] 	Writing dbuff1 to data file.  tmilli =  3160  took  12.59 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.06 mSec fill [lp#174908] 	Writing dbuff0 to data file.  tmilli =  3217  took  13.22 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.86 mSec fill [lp#174908] 	Writing dbuff1 to data file.  tmilli =  3275  took  12.64 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.01 mSec fill [lp#174908] 	Writing dbuff0 to data file.  tmilli =  3332  took  13.22 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.82 mSec fill [lp#174908] 	Writing dbuff1 to data file.  tmilli =  3390  took  12.59 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.04 mSec fill [lp#174908] 	Writing dbuff0 to data file.  tmilli =  3447  took  13.20 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.84 mSec fill [lp#174908] 	Writing dbuff1 to data file.  tmilli =  3505  took  12.60 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  58.06 mSec fill [lp#174908] 	Writing dbuff0 to data file.  tmilli =  3562  took  13.22 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.85 mSec fill [lp#174908] 	Writing dbuff1 to data file.  tmilli =  3620  took  12.64 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  57.97 mSec fill [lp#5] 	Writing dbuff0 to data file.  tmilli =  3677  took  13.17 mSec
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1]  56.92 mSec fill [lp#5] 	Writing dbuff1 to data file.  tmilli =  3735  took  12.65 mSec
 	 BUFF at 70050000
	DONE 18379 >> 1019, 20375, 70097CB0, 1
0]  57.97 mSec fill [lp#5] 	Writing dbuff0 to data file.  tmilli =  3792  took  13.18 mSec
Stopping logging

ADCTimer halted

1216 KBytes written to file.
 
Running code ... Things still not right for the eRAM replacing the Direct access ... gotta eat now ...

This has to be wrong in ADCChore_eRAM()?
saveidx += sizeof(datrec);
if (saveidx >= BUFFSIZE) { // mark buffer for write to SD
BUFFSIZE is number of structs to be allocated, and in ADCChore_eRAM() use it is not saveidx++ like in the ADCChore() but saveidx += sizeof(datrec)

Good with the fix to WriteBinary() to use the same read method as write. I see added method ='r' dupes the logging now set: if ( logging == 1 ) ADCChore(); else if ( logging == 2 ) ADCChore_eRAM();
The final "DONE" line still uses direct access to get that last dump though:
Serial.printf("\tDONE %lu >> %lu, %lu, %lX, %lu\n", kk, drp[kk].millitime, drp[kk].microtime, drp[kk].DWTCount, drp[kk].byteswritten);
 
Updated two func()'s below. Shows END address when buffer swaps - indeed it is running 16 times faster because it is quitting after BUFFSIZE bytes , not datrec structs - so it isn't using the same full buffer.

This explains why running 'r' before 'R' works - because the 'r' leaves parse-able data in eRam to pass the Sparse check. See prior post #360 ( and earlier )

ALSO FUNNY is Direct starts on dbuff1? and eRAM starts on sbuff0_addr ????

Code now prints the "# FULL" when it swaps buffer where # is 0 or 1 just 'filled' - then the end effective address is printed:
Code:
[B]PSRAM DIRECT _isr() logging[/B]
		 0 FULL D @ 18380 &dbuff>[B]70097CC0[/B]
 	 BUFF at 70050000
 	 HIDE overWrap of 5  <<<<< 
skipped 6	1, 6, 70050060, 0	 	 kk==6  ????
 	 HIDE firstWrap of 19  <<<<< 
skipped 17	919, 18380, 70090000, 1	 	 kk==16384  ????
skipped 0	919, 18381, 70090010, 1	 	 kk==16385  ????
skipped 8	827, 16526, 700908E0, 0	 	 kk==16526  ????
	DONE 18379 >> 919, 18379, 70097CB0, 0
0] 926.41 mSec fill [lp#4440473] 	Writing dbuff0 to data file.  tmilli =  0  took   7.41 mSec
		 1 FULL D @ 18380 &dbuff>[B]700D7CC0[/B]
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1] 919.00 mSec fill [lp#4440473] 	Writing dbuff1 to data file.  tmilli =  919  took   7.42 mSec
		 0 FULL D @ 18380 &dbuff>70097CC0

versus eRAM:
Code:
[B]PSRAM eRAM _isr() logging[/B]
		 0 FULL e @ 18384 sbuff>[B]700547D0[/B] 
 	 BUFF at 70050000
 	 HIDE overWrap of 4294967295  <<<<< 
 	 HIDE firstWrap of 0  <<<<< 
	DONE 18379 >> 4695, 93895, 70097CB0, 1
0]  69.96 mSec fill [lp#5356625] 	Writing dbuff0 to data file.  tmilli =  0  took  12.50 mSec
		 1 FULL e @ 18384 sbuff>[B]700947D0[/B] 
 	 BUFF at 70090000
	DONE 18379 >> 5514, 110279, 700D7CB0, 1
1]  57.54 mSec fill [lp#5356625] 	Writing dbuff1 to data file.  tmilli =  57  took  12.60 mSec
		 0 FULL e @ 18384 sbuff>700547D0


Code:
void ADCChore_eRAM(void) { // eRAM function access
#ifdef USE_PSRAM // avoid eRAM non-def error on RAM only test
  uint32_t tmilli;
  tmilli = millis() - filestartmilli;
  byteswritten += sizeof(datrec); // update global bytes written count
  // save in  the proper buffer--defined by savebuffnum
  if (savebuffnum == 0) { // put data in dbuff0
    writeLong(sbuff0_addr + saveidx , tmilli);
    writeLong(sbuff0_addr + saveidx + 4, logIndex++);
    writeLong(sbuff0_addr + saveidx + 8, (uint32_t)sbuff0_addr + (sizeof(datrec) * saveidx));
    writeLong(sbuff0_addr + saveidx + 12, 0);
    saveidx += sizeof(datrec);
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL e @ %lu sbuff>%lX \n", savebuffnum, saveidx, sbuff0_addr+ saveidx);
      writebuffnum = 0;
      savebuffnum = 1;   // start saving in other buffer on next interrupt
      saveidx = 0;  // start at beginning of next buffer
    }
  } else {  // must be saving to dbuff1
    writeLong(sbuff1_addr + saveidx , tmilli);
    writeLong(sbuff1_addr + saveidx  + 4, logIndex++);
    writeLong(sbuff1_addr + saveidx  + 8, (uint32_t)sbuff1_addr + (sizeof(datrec) * saveidx));
    writeLong(sbuff1_addr + saveidx  + 12, 1);
    saveidx += sizeof(datrec);
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL e @ %lu sbuff>%lX \n", savebuffnum, saveidx, sbuff1_addr+ saveidx);
      writebuffnum = 1;
      savebuffnum = 0;   // start saving in other buffer on next interrupt
      saveidx = 0;   // start at beginning of next buffer
    }
  }
#endif
}

void ADCChore(void) { // DIRECT ACCESS
  uint32_t tmilli;
  tmilli = millis() - filestartmilli;
  byteswritten += sizeof(datrec); // update global bytes written count
  // save in  the proper buffer--defined by savebuffnum
  if (savebuffnum == 0) { // put data in dbuff0
    dbuff0[saveidx].millitime = tmilli;
    dbuff0[saveidx].microtime =  logIndex++;
    dbuff0[saveidx].DWTCount = (uint32_t)dbuff0 + (sizeof(datrec) * saveidx);;
    dbuff0[saveidx].byteswritten = 0;
    saveidx++;
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL D @ %lu &dbuff>%lX\n", savebuffnum, saveidx, (uint32_t)&dbuff0[saveidx]);
      writebuffnum = 0;
      savebuffnum = 1;   // start saving in other buffer on next interrupt
      saveidx = 0;  // start at beginning of next buffer
    }
  } else {  // must be saving to dbuff1
    dbuff1[saveidx].millitime = tmilli;
    dbuff1[saveidx].microtime =  logIndex++;
    dbuff1[saveidx].DWTCount = (uint32_t)dbuff1 + (sizeof(datrec) * saveidx);;
    //dbuff1[saveidx].byteswritten = byteswritten;
    dbuff1[saveidx].byteswritten = 1;
    saveidx++;
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL D @ %lu &dbuff>%lX\n", savebuffnum, saveidx, (uint32_t)&dbuff1[saveidx]);
      writebuffnum = 1;
      savebuffnum = 0;   // start saving in other buffer on next interrupt
      saveidx = 0;   // start at beginning of next buffer
    }
  }
}
 
Ok - did you download the latest version of @Frank B's T4_PowerButton. Had that problem when first got a T4.1 where it would cause the sketch to hang like you described. Isolated down to same function and Frank put a fix in for his library.

Try downloading the latest version and give your sketch a go again.

Mike

I downloaded @Frank B's T4_PowerButton library and installed on Arduino 1.8.12 and TD 1.52B4 on the T4.1. It works great without any detectable problems.

Thanks
 
@defragster said:
BUFFSIZE is number of structs to be allocated, and in ADCChore_eRAM() use it is not saveidx++ like in the ADCChore() but saveidx += sizeof(datrec)
Strange - when I first incorporated eRAM I had just saveidx++ somewhere along the line it got changed.

The final "DONE" line still uses direct access to get that last dump though:
Now fixed

Still have to do the 'r' first. Have to sort that out.
 
TOO nice and sunny here - keep wanting to wander or sit outside. Gave our greenhouse to the neighbor for his wife's Mother's Day. Was just out clearing some mess from that. The two paths over there are #1 brushy and #2 blocked with a fallen cherry tree - so those are begging to be cleared and the grass needs cut. But after good working temps in the 50's - low 70's is HOT :)

Strange - when I first incorporated eRAM I had just saveidx++ somewhere along the line it got changed.

Now fixed

Still have to do the 'r' first. Have to sort that out.

For the Direct saveidx++ is right as the pointer is to the struct. But in eRam it is just a value added : "sbuff1_addr + saveidx"

So left it alone as would need in that context :: saveidx += sizeof(datrec);

Though perhaps I 'cleaned something up' and broke that without being able to tell since it was broken before :confused:

NOTE for using eFLASH variant - the eFLASH buffer will need a FORMAT whenever this appears :: saveidx = 0;

Bummer is we are no closer to knowing why this Direct method fails with _isr() - the code can handle buffers same size in RAM - and the PSRAM works when _isr() disabled for timed call from loop():
Code:
 	 BUFF at 70050000
skipped 17	2757, 55140, 70090000, 1	 	 kk==16384  ????
skipped 0	2757, 55141, 70090010, 1	 	 kk==16385  ????
skipped 8	2665, 53286, 700908E0, 0	 	 kk==16526  ????

Does the _isr() fool the cache? or leave something undone? Does the _isr() double fire? And why only and always on that address boundary? It isn't a case where "DSB in _isr() helps.
 
Ok figured out the major problem with the sketch, numstructs in writeBinary needs to be numstructs/sizeof(datrec) since I am reading in 16 bytes at a time and saveidx += sizeof(datrec) is correct. Still get 1 skip though - soon I guess I will figure that one out. Now to make wife diner for mothers day:
Code:
/**************************************************************
  timing PSRAM datalogger for Teensy 4.1 with PSRAM - NO SD LOGGING - ONLY extRAM_t4.h required

  https://forum.pjrc.com/threads/60754-Teensy-3-6-SD-Card-missing-time-in-milliseconds?p=238352&viewfull=1#post238352
  Written for Teensy 3.6 by M. Borgerson  May 7, 2020
********************************************************************/

elapsedMicros logTime;
//#define USE_logtime
#define LOG_US (1000000 / SAMPLERATE)
#ifdef USE_logtime
#else
IntervalTimer ADCTimer;
#endif

struct datrec {
  uint32_t millitime;
  uint32_t microtime;
  uint32_t DWTCount;
  uint32_t byteswritten;
};

uint32_t logIndex = 0;
#define SAMPLERATE 20000
#define USE_PSRAM 1
#ifdef USE_PSRAM
#include <extRAM_t4.h>
extRAM_t4 eRAM;
#define BUFFSIZE  9190*2
//uint8_t config = 2; //0 - init eram only, 1-init flash only, 2-init both
//These have been replaced with defines for:
//INIT_PSRAM_ONLY
//INIT_FLASH_ONLY
//INIT_PSRM_FLASH
uint8_t config = INIT_PSRAM_ONLY;
// FAILS with 0x70050000 at offset 0x4000
struct datrec *dbuff0 = (datrec *)0x70050000;
struct datrec *dbuff1 = (datrec *)0x70090000;
uint32_t sbuff0_addr = 0x70050000;
uint32_t sbuff1_addr = 0x70090000;

//define a struct joining MYDATA_t to an array of bytes to be stored
uint32_t arraySize = sizeof(datrec);
typedef union MYDATA4RAM_t {
 datrec datastruct;
 uint8_t Packet[sizeof(datrec)];
};
MYDATA4RAM_t readdata; //data read from memory


#else  // THIS USES RAM1 and RAM2 buffer to show _isr() log works with same size buffers
#define BUFFSIZE  9190*2
struct datrec dbuff1[BUFFSIZE];
struct datrec *dbuff0 = (datrec *)malloc(BUFFSIZE*sizeof(datrec));
#endif


#define DEBUGPRINT true

int logging = 0;

char method = 0;

// these variables are declared volatile because they are changed or used in the
// interrupt handler
volatile uint16_t saveidx = 0;
volatile int16_t writebuffnum = -1;
volatile uint16_t savebuffnum = 0;
volatile uint32_t filestartmilli = 0;
volatile uint32_t byteswritten = 0;

const int ledpin = 13;

#define LEDON  digitalWriteFast(ledpin, HIGH);
#define LEDOFF digitalWriteFast(ledpin, LOW);

const char compileTime [] = "Timing Data Logger  Compiled on " __DATE__ " " __TIME__;
void setup() {
  if ( ARM_DWT_CYCCNT == ARM_DWT_CYCCNT ) {   // activate ARM cycle counter
    ARM_DEMCR |= ARM_DEMCR_TRCENA; // Assure Cycle Counter active
    ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
  }

  pinMode(ledpin, OUTPUT);
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial && millis() < 4000 );
  Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
  Serial.println(compileTime);
  // see if the card is present and can be initialized:
  Serial.print("Initializing SD card...");

#ifdef USE_PSRAM
  eRAM.begin(config);
  Serial.print("Start PSRAM for LOGGING :: ");
#else
  Serial.print("LOGGING from RAM :: ");
#endif

  Serial.printf("\nTwin buffers of size %u Bytes\n" , sizeof(datrec)*BUFFSIZE );
  Serial.println("Enter command selected from ( r, R{eRAM}, q, s, f )");
}

void FastBlink(void) {  // blink forever
  while (1) {
    LEDON
    delay(50);
    LEDOFF
    delay(50);
  }
}

static uint32_t elapsedUS = 0;
uint32_t loopCnt = 0, loopSpd;
elapsedMillis elapsedLoop = 0;
void loop() {
  // put your main code here, to run repeatedly:
  char ch;
  uint32_t microselapsed;
  elapsedMicros wrtelapsed = 0;
  loopCnt++;
  if ( elapsedLoop >= 1000 ) {
    loopSpd = loopCnt;
    loopCnt = 0;
    elapsedLoop -= 1000;
  }

#ifdef USE_logtime
  if ( logging && logTime > LOG_US ) {
    logTime -= LOG_US;
    if ( logging == 1 )
      ADCChore();
    esle if ( logging == 2 )
      ADCChore_eRAM();
  }
#endif

  if (Serial.available()) {
    ch = Serial.read();
    if (ch == 'r') {
      method = ch;
      StartLogging(1);
    }
    if (ch == 'R') {
#ifdef USE_PSRAM
      method = ch;
      StartLogging(2);
#endif
    }
    if (ch == 'E') {
      eRAM.eraseDevice();
    }
    if (ch == 's') {
      StopLogging();
      Serial.print("SUCCESS:: working address ZERO at 0x70000000");
      dbuff0 = (datrec *)0x70000000;
      dbuff1 = (datrec *)0x70090000;
      sbuff0_addr = 0x70000000;
      sbuff1_addr = 0x70090000;
    }

    if (ch == 'f') {  // FAILS with 0x70050000 at offset 0x4000
      StopLogging();
      Serial.print("FAIL:: working address ZERO at 0x70050000");
      dbuff0 = (datrec *)0x70050000;
      dbuff1 = (datrec *)0x70090000;
      sbuff0_addr = 0x70050000;
      sbuff1_addr = 0x70090000;
    }

    if (ch == 'q') StopLogging();
  }
  // Now check to see if a buffer is ready to be written to SD
  // writebuffnum will be set in the interrupt handler
  if (writebuffnum == 0) { //is dbuff0 ready?
    LEDON
    writebuffnum = -1;
    if (1) { //if the file is open write dbuff0
      wrtelapsed = 0;
      WriteBinary(&dbuff0[0], BUFFSIZE);
      microselapsed = wrtelapsed;
      if (DEBUGPRINT) {
        loopCnt = loopCnt / (micros() - elapsedUS);
        Serial.printf("0] %6.2f mSec fill [lp#%lu] \t", (float)(micros() - elapsedUS) / 1000.0, loopSpd );
        Serial.print("Writing dbuff0 to data file.  tmilli = ");
        Serial.printf(" %lu  took %6.2f mSec\n", dbuff0[0].millitime, (float)microselapsed / 1000.0);
        elapsedUS = micros();
      }
    }
    LEDOFF
  }
  else if (writebuffnum == 1) { // is dbuff1 ready?
    LEDON
    writebuffnum = -1;
    if (1) { //if the file is open write dbuff0
      wrtelapsed = 0;
      WriteBinary(&dbuff1[0], BUFFSIZE);
      microselapsed = wrtelapsed;
      if (DEBUGPRINT) {
        loopCnt = loopCnt / (micros() - elapsedUS);
        Serial.printf("1] %6.2f mSec fill [lp#%lu] \t", (float)(micros() - elapsedUS) / 1000.0, loopSpd );
        Serial.print("Writing dbuff1 to data file.  tmilli = ");
        Serial.printf(" %lu  took %6.2f mSec\n", dbuff1[0].millitime, (float)(microselapsed) / 1000.0);
        elapsedUS = micros();
      }
    }
    LEDOFF
  }
  //delay(5);
}  // end of the loop() function

// write a buffer to the file as binary record. This  takes more time and file space than
// binary format, but can be directly read on PC.
// Note that we have to cast datrec pointer to a uint8_t pointer
// to keep the SD libraryhappy
static uint32_t firstWrap = 999;
static uint32_t overWrap = 999;
void WriteBinary(volatile struct datrec *drp, size_t numstructs) {

//  dataFile.write((uint8_t *)drp, numstructs * sizeof(datrec));

  Serial.printf(" \t BUFF at %lX\n", drp );
  uint32_t lastM = 0;
  uint32_t kk, lastB = 5;
  uint32_t ii = 0, iiL = 0;
  if(method == 'r'){
      lastB = drp[0].byteswritten;
      for ( kk = 0; kk < numstructs; kk++) {
        if ( lastM != drp[kk].millitime || lastB != drp[kk].byteswritten ) {
          if ( overWrap == 999 ) {
            overWrap = ii - 1;
            Serial.printf(" \t HIDE overWrap of %lu  <<<<< \n", overWrap );
          }
          else if ( firstWrap == 999 ) {
            firstWrap = ii;
            Serial.printf(" \t HIDE firstWrap of %lu  <<<<< \n", firstWrap );
          }
          if ( lastM != drp[kk].millitime )
            lastM = drp[kk].millitime;
    
          if ( ii != iiL && ii != firstWrap && ii != overWrap ) {
            Serial.printf("skipped %lu\t", ii);
            Serial.printf("%lu, %lu, %lX, %lu\t", drp[kk].millitime, drp[kk].microtime, drp[kk].DWTCount, drp[kk].byteswritten);
            Serial.printf(" \t kk==%lu  ????\n", kk );
          }
          iiL = ii;
          ii = 0;
        }
        else
          ii++;
      }
      kk = numstructs - 1;
      Serial.printf("\tDONE %lu >> %lu, %lu, %lX, %lu\n", kk, drp[kk].millitime, drp[kk].microtime, drp[kk].DWTCount, drp[kk].byteswritten);
    
      //dataFile.write((uint8_t *)drp, numstructs * sizeof(datrec));
  } else {
    uint32_t ramAddr = (uint32_t *)drp;
      uint32_t vmillitime = 0, vmicrotime = 0, vDWTCount = 0, vbyteswritten = 0;
      readArray(ramAddr, arraySize, readdata.Packet);
      lastB = readdata.datastruct.byteswritten;
      for ( kk = 0; kk < numstructs/sizeof(datrec); kk++) {
        readArray(ramAddr+arraySize*kk, arraySize, readdata.Packet);
        vmillitime = readdata.datastruct.millitime;
        vmicrotime = readdata.datastruct.microtime;
        vDWTCount = readdata.datastruct.DWTCount;
        vbyteswritten = readdata.datastruct.byteswritten;
        if ( lastM != vmillitime || lastB != vbyteswritten ) {
          if ( overWrap == 999 ) {
            overWrap = ii - 1;
            Serial.printf(" \t HIDE overWrap of %lu  <<<<< \n", overWrap );
          }
          else if ( firstWrap == 999 ) {
            firstWrap = ii;
            Serial.printf(" \t HIDE firstWrap of %lu  <<<<< \n", firstWrap );
          }
          if ( lastM != vmillitime )
            lastM = vmillitime;
    
          if ( ii != iiL && ii != firstWrap && ii != overWrap ) {
            Serial.printf("skipped %lu\t", ii);
            Serial.printf("%lu, %lu, %lX, %lu\t", vmillitime, vmicrotime, vDWTCount, vbyteswritten);
            Serial.printf(" \t kk==%lu  ????\n", kk );
          }
          iiL = ii;
          ii = 0;
        }
        else
          ii++;
      }
      kk = numstructs - 1;
      Serial.printf("\tDONE %lu >> %lu, %lu, %lX, %lu\n", kk, vmillitime, vmicrotime, vDWTCount, vbyteswritten);
    
      //dataFile.write((uint8_t *)drp, numstructs * sizeof(datrec));
  }
}

void ADCChore_eRAM(void) { // eRAM function access
#ifdef USE_PSRAM // avoid eRAM non-def error on RAM only test
  uint32_t tmilli;
  tmilli = millis() - filestartmilli;
  byteswritten += sizeof(datrec); // update global bytes written count
  // save in  the proper buffer--defined by savebuffnum
  if (savebuffnum == 0) { // put data in dbuff0
    writeLong(sbuff0_addr + saveidx , tmilli);
    writeLong(sbuff0_addr + saveidx + 4, logIndex++);
    writeLong(sbuff0_addr + saveidx + 8, (uint32_t)sbuff0_addr + (sizeof(datrec) * saveidx));
    writeLong(sbuff0_addr + saveidx + 12, 0);
    saveidx += sizeof(datrec);
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL e @ %lu sbuff>%lX \n", savebuffnum, saveidx, sbuff0_addr+ saveidx);
      writebuffnum = 0;
      savebuffnum = 1;   // start saving in other buffer on next interrupt
      saveidx = 0;  // start at beginning of next buffer
    }
  } else {  // must be saving to dbuff1
    writeLong(sbuff1_addr + saveidx , tmilli);
    writeLong(sbuff1_addr + saveidx  + 4, logIndex++);
    writeLong(sbuff1_addr + saveidx  + 8, (uint32_t)sbuff1_addr + (sizeof(datrec) * saveidx));
    writeLong(sbuff1_addr + saveidx  + 12, 1);
    saveidx += sizeof(datrec);
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL e @ %lu sbuff>%lX \n", savebuffnum, saveidx, sbuff1_addr+ saveidx);
      writebuffnum = 1;
      savebuffnum = 0;   // start saving in other buffer on next interrupt
      saveidx = 0;   // start at beginning of next buffer
    }
  }
#endif
}

void ADCChore(void) { // DIRECT ACCESS
  uint32_t tmilli;
  tmilli = millis() - filestartmilli;
  byteswritten += sizeof(datrec); // update global bytes written count
  // save in  the proper buffer--defined by savebuffnum
  if (savebuffnum == 0) { // put data in dbuff0
    dbuff0[saveidx].millitime = tmilli;
    dbuff0[saveidx].microtime =  logIndex++;
    dbuff0[saveidx].DWTCount = (uint32_t)dbuff0 + (sizeof(datrec) * saveidx);;
    dbuff0[saveidx].byteswritten = 0;
    saveidx++;
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL D @ %lu &dbuff>%lX\n", savebuffnum, saveidx, (uint32_t)&dbuff0[saveidx]);
      writebuffnum = 0;
      savebuffnum = 1;   // start saving in other buffer on next interrupt
      saveidx = 0;  // start at beginning of next buffer
    }
  } else {  // must be saving to dbuff1
    dbuff1[saveidx].millitime = tmilli;
    dbuff1[saveidx].microtime =  logIndex++;
    dbuff1[saveidx].DWTCount = (uint32_t)dbuff1 + (sizeof(datrec) * saveidx);;
    //dbuff1[saveidx].byteswritten = byteswritten;
    dbuff1[saveidx].byteswritten = 1;
    saveidx++;
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL D @ %lu &dbuff>%lX\n", savebuffnum, saveidx, (uint32_t)&dbuff1[saveidx]);
      writebuffnum = 1;
      savebuffnum = 0;   // start saving in other buffer on next interrupt
      saveidx = 0;   // start at beginning of next buffer
    }
  }
}

void StartLogging(int logType) {
  // we open in a mode that creates a new file each time
  // instead of appending as in the Arduino example
  if ( logging ) return;
  logging = logType;
  elapsedUS = micros();
  loopCnt = 0;
  firstWrap = 999;
  overWrap = 999;
  logIndex = 0;

  Serial.println("Starting logging");

  // initialize some variables for the buffers
  saveidx = 0;   // start saving at beginning of buffer
  savebuffnum = 0;  // start saving in dbuff0
  writebuffnum = -1;  // indicates no buffer ready yet
  //  start the interval timer to begin logging
  filestartmilli = millis();
  byteswritten = 0;
#ifdef USE_logtime
  logTime = 0;
#else
  if ( logging == 1 ) {
    Serial.println("PSRAM DIRECT _isr() logging");
    ADCTimer.begin(ADCChore, 1000000 / SAMPLERATE); //begin() expects timer period in microseconds
  }
  else if ( logging == 2 ) {
    Serial.println("PSRAM eRAM _isr() logging");
    ADCTimer.begin(ADCChore_eRAM, 1000000 / SAMPLERATE); //begin() expects timer period in microseconds
  }
#endif

}

void StopLogging(void) {
  if ( 0 == logging ) return;
  Serial.println("Stopping logging");
  logging = 0;
#ifdef USE_logtime
  logTime = 0;
  if (DEBUGPRINT) Serial.println("eMicros Log halted");
#else
  ADCTimer.end();
  if (DEBUGPRINT) Serial.println("ADCTimer halted");
#endif
  delay(10);
  writebuffnum = -1;
  Serial.printf("%lu KBytes written to file.\n", byteswritten / 1024);
  // in the interest of simplicity, we ignore any partial buffer at the end
}

void readArray (uint32_t ramAddr, uint32_t length, uint8_t *data)
{
  uint32_t ii;
  uint8_t *ptrERAM = (uint8_t *)(ramAddr);

  //uint32_t timenow = micros();
  for ( ii = 0; ii < length; ii++ ) {
    data[ii] = ptrERAM[ii];
  }
  //Serial.printf("Read (us): %d\n", micros()-timenow);
  //Serial.printf("read @%06X: ", ramAddr);
  //for (uint32_t i=0; i < length; i++) Serial.printf(" %02X", *(((uint8_t *)data) + i));
  //Serial.printf("\n");
  //Serial.printf("rd @%08X: ", (uint32_t)ptrERAM);
  //for (uint32_t i=0; i < length; i++) Serial.printf(" %02X", ptrERAM[i]);
  //Serial.printf("\n");
}

void writeArray (uint32_t ramAddr, uint32_t items, uint8_t values[])
{ 
  uint32_t ii;
  uint8_t *ptrERAM = (uint8_t *)(ramAddr);
  
  //Serial.printf("write @%06X:\n", ramAddr);
  //for (uint32_t i=0; i < items; i++) Serial.printf(" %02X", *(((uint8_t *)values) + i));
  //Serial.printf("\n");
  //uint32_t timenow = micros();
  for ( ii = 0; ii < items; ii++ ) {
    ptrERAM[ii] = values[ii];
  }
  //Serial.printf("Write (us): %d\n", micros()-timenow);

}

void writeLong(uint32_t ramAddr, uint32_t value)
{
  uint8_t *buffer = reinterpret_cast<uint8_t *>(&value);
  writeArray(ramAddr, 4, buffer);
  
}

void readLong(uint32_t ramAddr, uint32_t *value)
{
  uint8_t buffer[4];
  readArray(ramAddr, 4, buffer);
  *value = *reinterpret_cast<uint32_t *>(buffer);

}
 
Cool - got the latest code. Still R faster than r as shown in the tmilli value on writing the buffer is setting FULL given the sample rate is the same.
Also the LoopCycleCount :: Direct [lp#2,757,200] versus eRAM [lp#232,102]
Direct is 919 ms to fill:
Code:
0] 926.74 mSec fill [lp#1938540] 	Writing dbuff0 to data file.  tmilli =  0  took   7.73 mSec
1] 918.69 mSec fill [lp#2326574] 	Writing dbuff1 to data file.  tmilli =  919  took   7.43 mSec
0] 918.93 mSec fill [lp#2757200] 	Writing dbuff0 to data file.  tmilli =  1838  took   7.38 mSec
1] 919.03 mSec fill [lp#3186559] 	Writing dbuff1 to data file.  tmilli =  2757  took   7.42 mSec

versus eRAM is 57 ms to fill:
Code:
0]  57.59 mSec fill [lp#4917556] 	Writing dbuff0 to data file.  tmilli =  0  took   0.13 mSec
1]  57.86 mSec fill [lp#232102] 	Writing dbuff1 to data file.  tmilli =  57  took   0.55 mSec
0]  57.10 mSec fill [lp#232102] 	Writing dbuff0 to data file.  tmilli =  115  took   0.21 mSec
1]  57.38 mSec fill [lp#232102] 	Writing dbuff1 to data file.  tmilli =  172  took   0.15 mSec

So the R code doesn't seem to be working the same task?
 
'R' method seems to be working as it should now - before or after 'r' or first on cold start.
And detection of buffer cross write on DIRECT uasge is there when eRAM doesn't trigger that. :(

Pretty sure this was my bad opps … here is the restored code:
Code:
void ADCChore_eRAM(void) { // eRAM function access
#ifdef USE_PSRAM // avoid eRAM non-def error on RAM only test
  uint32_t tmilli;
  tmilli = millis() - filestartmilli;
  byteswritten += sizeof(datrec); // update global bytes written count
  // save in  the proper buffer--defined by savebuffnum
  if (savebuffnum == 0) { // put data in dbuff0
    writeLong(sbuff0_addr + saveidx*sizeof(datrec) , tmilli);
    writeLong(sbuff0_addr + saveidx*sizeof(datrec) + 4, logIndex++);
    writeLong(sbuff0_addr + saveidx*sizeof(datrec) + 8, (uint32_t)sbuff0_addr + (sizeof(datrec) * saveidx));
    writeLong(sbuff0_addr + saveidx*sizeof(datrec) + 12, 0);
    saveidx ++;
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL e @ %lu sbuff>%lX \n", savebuffnum, saveidx, sbuff0_addr+ saveidx);
      writebuffnum = 0;
      savebuffnum = 1;   // start saving in other buffer on next interrupt
      saveidx = 0;  // start at beginning of next buffer
    }
  } else {  // must be saving to dbuff1
    writeLong(sbuff1_addr + saveidx*sizeof(datrec) , tmilli);
    writeLong(sbuff1_addr + saveidx*sizeof(datrec)  + 4, logIndex++);
    writeLong(sbuff1_addr + saveidx*sizeof(datrec)  + 8, (uint32_t)sbuff1_addr + (sizeof(datrec) * saveidx));
    writeLong(sbuff1_addr + saveidx*sizeof(datrec)  + 12, 1);
    saveidx ++;
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL e @ %lu sbuff>%lX \n", savebuffnum, saveidx, sbuff1_addr+ saveidx);
      writebuffnum = 1;
      savebuffnum = 0;   // start saving in other buffer on next interrupt
      saveidx = 0;   // start at beginning of next buffer
    }
  }
#endif
}

Seem to be back on task now for eRAM:
Code:
PSRAM eRAM _isr() logging
		[B] 0 FULL e @ 18380 sbuff>700547CC [/B]
 	 BUFF at 70050000
 	 HIDE overWrap of 4  <<<<< 
skipped 5	1, 5, 70050050, 0	 	 kk==5  ????
 	 HIDE firstWrap of 19  <<<<< 
	DONE 18379 >> 58, 1147, 700547B0, 0
0] 919.30 mSec fill [lp#3759791] 	Writing dbuff0 to data file.  tmilli =  0  took   0.29 mSec
		[B] 1 FULL e @ 18380 sbuff>700947CC [/B]
 	 BUFF at 70090000
	DONE 18379 >> 977, 19527, 700947B0, 1
1] 919.28 mSec fill [lp#4188145] 	Writing dbuff1 to data file. [B] tmilli =  919[/B]  took   0.59 mSec
		 0 FULL e @ 18380 sbuff>700547CC
… and Direct
Code:
PSRAM DIRECT _isr() logging
		[B] 0 FULL D @ 18380 &dbuff>70097CC0[/B]
 	 BUFF at 70050000
 	 HIDE overWrap of 9  <<<<< 
skipped 10	1, 10, 700500A0, 0	 	 kk==10  ????
 	 HIDE firstWrap of 19  <<<<< 
[COLOR="#FF0000"][B]skipped 13	919, 18380, 70090000, 1	 	 kk==16384  ????
skipped 0	919, 18381, 70090010, 1	 	 kk==16385  ????[/B][/COLOR]
skipped 2	827, 16530, 70090920, 0	 	 kk==16530  ????
	DONE 18379 >> 919, 18379, 70097CB0, 0
0] 926.91 mSec fill [lp#3493527] 	Writing dbuff0 to data file.  tmilli =  0  took   7.90 mSec
		[B] 1 FULL D @ 18380 &dbuff>700D7CC0[/B]
 	 BUFF at 70090000
	DONE 18379 >> 1838, 36759, 700D7CB0, 1
1] 918.51 mSec fill [lp#3880648] 	Writing dbuff1 to data file.  [B]tmilli =  919[/B]  took   7.42 mSec
		 0 FULL D @ 18380 &dbuff>70097CC0

Though still need to see why they complete first buffer in alternate address order ...
 
Oh - been playing around with a slightly different version that just that I will try your updated code in it next but about done for the night. Try changing the samerate to 4000. Seems to make the skips go away for both 'r' and 'R' for both 's' and 'f'

EDIT: 8000 seems to work as well
'r' with 'f'
Code:
FAIL:: working address ZERO at 0x70050000Starting logging

PSRAM DIRECT _isr() logging

		 0 FULL D @ 16384 &dbuff>70090000
 	 BUFF at 70050000
 	 HIDE overWrap of 5  <<<<< 
skipped 6	1, 6, 70050060, 0	 	 kk==6  ????
 	 HIDE firstWrap of 7  <<<<< 
	DONE 16383 >> 2048, 16383, 7008FFF0, 0
0] 2054.70 mSec fill [lp#5332833] 	Writing dbuff0 to data file.  tmilli =  0  took   6.69 mSec
		 1 FULL D @ 16384 &dbuff>700D0000
 	 BUFF at 70090000
	DONE 16383 >> 4096, 32767, 700CFFF0, 1
1] 2047.84 mSec fill [lp#5332833] 	Writing dbuff1 to data file.  tmilli =  2048  took   6.54 mSec
		 0 FULL D @ 16384 &dbuff>70090000
 	 BUFF at 70050000
	DONE 16383 >> 6144, 49151, 7008FFF0, 0
0] 2047.97 mSec fill [lp#5332833] 	Writing dbuff0 to data file.  tmilli =  4096  took   6.52 mSec
'R' with 'f'
Code:
AIL:: working address ZERO at 0x70050000Starting logging

PSRAM eRAM _isr() logging

		 0 FULL e @ 16384 sbuff>70054000 
 	 BUFF at 70050000
 	 HIDE overWrap of 3  <<<<< 
skipped 4	1, 4, 70050040, 0	 	 kk==4  ????
 	 HIDE firstWrap of 7  <<<<< 
	DONE 1023 >> 128, 1023, 70053FF0, 0
0] 2048.74 mSec fill [lp#5290333] 	Writing dbuff0 to data file.  tmilli =  0  took   0.74 mSec
		 1 FULL e @ 16384 sbuff>70094000 
 	 BUFF at 70090000
	DONE 1023 >> 2176, 17407, 70093FF0, 1
1] 2047.82 mSec fill [lp#5290400] 	Writing dbuff1 to data file.  tmilli =  2048  took   0.56 mSec
		 0 FULL e @ 16384 sbuff>70054000 
 	 BUFF at 70050000
	DONE 1023 >> 4224, 33791, 70053FF0, 0
0] 2048.00 mSec fill [lp#5290333] 	Writing dbuff0 to data file.  tmilli =  4096  took   0.58 mSec
		 1 FULL e @ 16384 sbuff>70094000 
 	 BUFF at 70090000
	DONE 1023 >> 6272, 50175, 70093FF0, 1
1] 2047.78 mSec fill [lp#5290400] 	Writing dbuff1 to data file.  tmilli =  6144  took   0.36 mSec
 
@defragster - @KurtE
Here is a slightly different version that uses the addr as an offset to match whats in the library as well as reducing the samplerate to 8000. Also, just does the eRAM function. Used it to debug was easier:
Code:
/**************************************************************
  timing PSRAM datalogger for Teensy 4.1 with PSRAM - NO SD LOGGING - ONLY extRAM_t4.h required

  https://forum.pjrc.com/threads/60754-Teensy-3-6-SD-Card-missing-time-in-milliseconds?p=238352&viewfull=1#post238352
  Written for Teensy 3.6 by M. Borgerson  May 7, 2020
********************************************************************/

elapsedMicros logTime;
//#define USE_logtime
#define LOG_US (1000000 / SAMPLERATE)
#ifdef USE_logtime
#else
IntervalTimer ADCTimer;
#endif

struct datrec {
  uint32_t millitime;
  uint32_t microtime;
  uint32_t DWTCount;
  uint32_t byteswritten;
};

uint32_t logIndex = 0;
#define SAMPLERATE 8000
#define USE_PSRAM 1
#ifdef USE_PSRAM
#include <extRAM_t4.h>
extRAM_t4 eRAM;
#define BUFFSIZE  8192*2
//uint8_t config = 2; //0 - init eram only, 1-init flash only, 2-init both
//These have been replaced with defines for:
//INIT_PSRAM_ONLY
//INIT_FLASH_ONLY
//INIT_PSRM_FLASH
uint8_t config = INIT_PSRAM_ONLY;
// FAILS with 0x70050000 at offset 0x4000
struct datrec *dbuff0 = (datrec *)0x70050000;
struct datrec *dbuff1 = (datrec *)0x70090000;
uint32_t sbuff0_addr = 0x70050000;
uint32_t sbuff1_addr = 0x70090000;

//define a struct joining MYDATA_t to an array of bytes to be stored
uint32_t arraySize = sizeof(datrec);
typedef union MYDATA4RAM_t {
 datrec datastruct;
 uint8_t Packet[sizeof(datrec)];
};
MYDATA4RAM_t readdata; //data read from memory


#else  // THIS USES RAM1 and RAM2 buffer to show _isr() log works with same size buffers
#define BUFFSIZE  9190*2
struct datrec dbuff1[BUFFSIZE];
struct datrec *dbuff0 = (datrec *)malloc(BUFFSIZE*sizeof(datrec));
#endif


#define DEBUGPRINT true

int logging = 0;

char method = 0;

// these variables are declared volatile because they are changed or used in the
// interrupt handler
volatile uint16_t saveidx = 0;
volatile int16_t writebuffnum = -1;
volatile uint16_t savebuffnum = 0;
volatile uint32_t filestartmilli = 0;
volatile uint32_t byteswritten = 0;

const int ledpin = 13;

#define LEDON  digitalWriteFast(ledpin, HIGH);
#define LEDOFF digitalWriteFast(ledpin, LOW);

const char compileTime [] = "Timing Data Logger  Compiled on " __DATE__ " " __TIME__;
void setup() {
  if ( ARM_DWT_CYCCNT == ARM_DWT_CYCCNT ) {   // activate ARM cycle counter
    ARM_DEMCR |= ARM_DEMCR_TRCENA; // Assure Cycle Counter active
    ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
  }

  pinMode(ledpin, OUTPUT);
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial && millis() < 4000 );
  Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
  Serial.println(compileTime);
  // see if the card is present and can be initialized:
  Serial.print("Initializing SD card...");

#ifdef USE_PSRAM
  eRAM.begin(config);
  Serial.print("Start PSRAM for LOGGING :: ");
#else
  Serial.print("LOGGING from RAM :: ");
#endif

  Serial.printf("\nTwin buffers of size %u Bytes\n" , sizeof(datrec)*BUFFSIZE );
  Serial.println("Enter command selected from ( r, R{eRAM}, q, s, f )");
}

void FastBlink(void) {  // blink forever
  while (1) {
    LEDON
    delay(50);
    LEDOFF
    delay(50);
  }
}

static uint32_t elapsedUS = 0;
uint32_t loopCnt = 0, loopSpd;
elapsedMillis elapsedLoop = 0;
void loop() {
  // put your main code here, to run repeatedly:
  char ch;
  uint32_t microselapsed;
  elapsedMicros wrtelapsed = 0;
  loopCnt++;
  if ( elapsedLoop >= 1000 ) {
    loopSpd = loopCnt;
    loopCnt = 0;
    elapsedLoop -= 1000;
  }

#ifdef USE_logtime
  if ( logging && logTime > LOG_US ) {
    logTime -= LOG_US;
    if ( logging == 1 )
      ADCChore();
    else if ( logging == 2 )
      ADCChore_eRAM();
  }
#endif

  if (Serial.available()) {
    ch = Serial.read();
    if (ch == 'r') {
      method = ch;
      StartLogging(1);
    }
    if (ch == 'R') {
#ifdef USE_PSRAM
      method = ch;
      StartLogging(2);
#endif
    }
    if (ch == 'E') {
      eRAM.eraseDevice();
    }
    if (ch == 's') {
      StopLogging();
      Serial.print("SUCCESS:: working address ZERO at 0x70000000");
      dbuff0 = (datrec *)0x70000000;
      dbuff1 = (datrec *)0x70090000;
      sbuff0_addr = 0x70000000;
      sbuff1_addr = 0x70090000;
    }

    if (ch == 'f') {  // FAILS with 0x70050000 at offset 0x4000
      StopLogging();
      Serial.print("FAIL:: working address ZERO at 0x70050000");
      dbuff0 = (datrec *)0x70050000;
      dbuff1 = (datrec *)0x70090000;
      sbuff0_addr = 0x70050000;
      sbuff1_addr = 0x70090000;
    }

    if (ch == 'q') StopLogging();
  }
  // Now check to see if a buffer is ready to be written to SD
  // writebuffnum will be set in the interrupt handler
  if (writebuffnum == 0) { //is dbuff0 ready?
    LEDON
    writebuffnum = -1;
    if (1) { //if the file is open write dbuff0
      wrtelapsed = 0;
      WriteBinary(&dbuff0[0], BUFFSIZE);
      microselapsed = wrtelapsed;
      if (DEBUGPRINT) {
        loopCnt = loopCnt / (micros() - elapsedUS);
        Serial.printf("0] %6.2f mSec fill [lp#%lu] \t", (float)(micros() - elapsedUS) / 1000.0, loopSpd );
        Serial.print("Writing dbuff0 to data file.  tmilli = ");
        Serial.printf(" %lu  took %6.2f mSec\n", dbuff0[0].millitime, (float)microselapsed / 1000.0);
        elapsedUS = micros();
      }
    }
    LEDOFF
  }
  else if (writebuffnum == 1) { // is dbuff1 ready?
    LEDON
    writebuffnum = -1;
    if (1) { //if the file is open write dbuff0
      wrtelapsed = 0;
      WriteBinary(&dbuff1[0], BUFFSIZE);
      microselapsed = wrtelapsed;
      if (DEBUGPRINT) {
        loopCnt = loopCnt / (micros() - elapsedUS);
        Serial.printf("1] %6.2f mSec fill [lp#%lu] \t", (float)(micros() - elapsedUS) / 1000.0, loopSpd );
        Serial.print("Writing dbuff1 to data file.  tmilli = ");
        Serial.printf(" %lu  took %6.2f mSec\n", dbuff1[0].millitime, (float)(microselapsed) / 1000.0);
        elapsedUS = micros();
      }
    }
    LEDOFF
  }
  //delay(5);
}  // end of the loop() function

// write a buffer to the file as binary record. This  takes more time and file space than
// binary format, but can be directly read on PC.
// Note that we have to cast datrec pointer to a uint8_t pointer
// to keep the SD libraryhappy
static uint32_t firstWrap = 999;
static uint32_t overWrap = 999;
void WriteBinary(volatile struct datrec *drp, size_t numstructs) {

//  dataFile.write((uint8_t *)drp, numstructs * sizeof(datrec));

  Serial.printf(" \t BUFF at %lX\n", drp );
  uint32_t lastM = 0;
  uint32_t kk, lastB = 0;
  uint32_t ii = 0, iiL = 0;
  if(method == 'r'){
      lastB = drp[0].byteswritten;
      for ( kk = 0; kk < numstructs; kk++) {
        if ( lastM != drp[kk].millitime || lastB != drp[kk].byteswritten ) {
          if ( overWrap == 999 ) {
            overWrap = ii - 1;
            Serial.printf(" \t HIDE overWrap of %lu  <<<<< \n", overWrap );
          }
          else if ( firstWrap == 999 ) {
            firstWrap = ii;
            Serial.printf(" \t HIDE firstWrap of %lu  <<<<< \n", firstWrap );
          }
          if ( lastM != drp[kk].millitime )
            lastM = drp[kk].millitime;
    
          if ( ii != iiL && ii != firstWrap && ii != overWrap ) {
            Serial.printf("skipped %lu\t", ii);
            Serial.printf("%lu, %lu, %lX, %lu\t", drp[kk].millitime, drp[kk].microtime, drp[kk].DWTCount, drp[kk].byteswritten);
            Serial.printf(" \t kk==%lu  ????\n", kk );
          }
          iiL = ii;
          ii = 0;
        }
        else
          ii++;
      }
      kk = numstructs - 1;
      Serial.printf("\tDONE %lu >> %lu, %lu, %lX, %lu\n", kk, drp[kk].millitime, drp[kk].microtime, drp[kk].DWTCount, drp[kk].byteswritten);
    
      //dataFile.write((uint8_t *)drp, numstructs * sizeof(datrec));
  } else {
    uint32_t ramAddr = (uint32_t *)drp;
      uint32_t vmillitime = 0, vmicrotime = 0, vDWTCount = 0, vbyteswritten = 0;
      readArray(ramAddr, arraySize, readdata.Packet);
      lastB = readdata.datastruct.byteswritten;
      for ( kk = 0; kk < numstructs/sizeof(datrec); kk++) {
        readArray(ramAddr+arraySize*kk, arraySize, readdata.Packet);
        vmillitime = readdata.datastruct.millitime;
        vmicrotime = readdata.datastruct.microtime;
        vDWTCount = readdata.datastruct.DWTCount;
        vbyteswritten = readdata.datastruct.byteswritten;
        if ( lastM != vmillitime || lastB != vbyteswritten ) {
          if ( overWrap == 999 ) {
            overWrap = ii - 1;
            Serial.printf(" \t HIDE overWrap of %lu  <<<<< \n", overWrap );
          }
          else if ( firstWrap == 999 ) {
            firstWrap = ii;
            Serial.printf(" \t HIDE firstWrap of %lu  <<<<< \n", firstWrap );
          }
          if ( lastM != vmillitime )
            lastM = vmillitime;
    
          if ( ii != iiL && ii != firstWrap && ii != overWrap ) {
            Serial.printf("skipped %lu\t", ii);
            Serial.printf("%lu, %lu, %lX, %lu\t", vmillitime, vmicrotime, vDWTCount, vbyteswritten);
            Serial.printf(" \t kk==%lu  ????\n", kk );
          }
          iiL = ii;
          ii = 0;
        }
        else
          ii++;
      }
      kk = (numstructs/sizeof(datrec)) - 1;
      Serial.printf("\tDONE %lu >> %lu, %lu, %lX, %lu\n", kk, vmillitime, vmicrotime, vDWTCount, vbyteswritten);
      //dataFile.write((uint8_t *)drp, numstructs * sizeof(datrec));
  }
}

void ADCChore_eRAM(void) { // eRAM function access
#ifdef USE_PSRAM // avoid eRAM non-def error on RAM only test
  uint32_t tmilli;
  tmilli = millis() - filestartmilli;
  byteswritten += sizeof(datrec); // update global bytes written count
  // save in  the proper buffer--defined by savebuffnum
  if (savebuffnum == 0) { // put data in dbuff0
    writeLong(sbuff0_addr + saveidx*sizeof(datrec) , tmilli);
    writeLong(sbuff0_addr + saveidx*sizeof(datrec) + 4, logIndex++);
    writeLong(sbuff0_addr + saveidx*sizeof(datrec) + 8, (uint32_t)sbuff0_addr + (sizeof(datrec) * saveidx));
    writeLong(sbuff0_addr + saveidx*sizeof(datrec) + 12, 0);
    saveidx ++;
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL e @ %lu sbuff>%lX \n", savebuffnum, saveidx, sbuff0_addr+ saveidx);
      writebuffnum = 0;
      savebuffnum = 1;   // start saving in other buffer on next interrupt
      saveidx = 0;  // start at beginning of next buffer
    }
  } else {  // must be saving to dbuff1
    writeLong(sbuff1_addr + saveidx*sizeof(datrec) , tmilli);
    writeLong(sbuff1_addr + saveidx*sizeof(datrec)  + 4, logIndex++);
    writeLong(sbuff1_addr + saveidx*sizeof(datrec)  + 8, (uint32_t)sbuff1_addr + (sizeof(datrec) * saveidx));
    writeLong(sbuff1_addr + saveidx*sizeof(datrec)  + 12, 1);
    saveidx ++;
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL e @ %lu sbuff>%lX \n", savebuffnum, saveidx, sbuff1_addr+ saveidx);
      writebuffnum = 1;
      savebuffnum = 0;   // start saving in other buffer on next interrupt
      saveidx = 0;   // start at beginning of next buffer
    }
  }
#endif
}

void ADCChore(void) { // DIRECT ACCESS
  uint32_t tmilli;
  tmilli = millis() - filestartmilli;
  byteswritten += sizeof(datrec); // update global bytes written count
  // save in  the proper buffer--defined by savebuffnum
  if (savebuffnum == 0) { // put data in dbuff0
    dbuff0[saveidx].millitime = tmilli;
    dbuff0[saveidx].microtime =  logIndex++;
    dbuff0[saveidx].DWTCount = (uint32_t)dbuff0 + (sizeof(datrec) * saveidx);;
    dbuff0[saveidx].byteswritten = 0;
    saveidx++;
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL D @ %lu &dbuff>%lX\n", savebuffnum, saveidx, (uint32_t)&dbuff0[saveidx]);
      writebuffnum = 0;
      savebuffnum = 1;   // start saving in other buffer on next interrupt
      saveidx = 0;  // start at beginning of next buffer
    }
  } else {  // must be saving to dbuff1
    dbuff1[saveidx].millitime = tmilli;
    dbuff1[saveidx].microtime =  logIndex++;
    dbuff1[saveidx].DWTCount = (uint32_t)dbuff1 + (sizeof(datrec) * saveidx);;
    //dbuff1[saveidx].byteswritten = byteswritten;
    dbuff1[saveidx].byteswritten = 1;
    saveidx++;
    if (saveidx >= BUFFSIZE) { // mark buffer for write to  SD
      Serial.printf("\t\t %d FULL D @ %lu &dbuff>%lX\n", savebuffnum, saveidx, (uint32_t)&dbuff1[saveidx]);
      writebuffnum = 1;
      savebuffnum = 0;   // start saving in other buffer on next interrupt
      saveidx = 0;   // start at beginning of next buffer
    }
  }
}

void StartLogging(int logType) {
  // we open in a mode that creates a new file each time
  // instead of appending as in the Arduino example
  if ( logging ) return;
  logging = logType;
  elapsedUS = micros();
  loopCnt = 0;
  firstWrap = 999;
  overWrap = 999;
  logIndex = 0;

  Serial.println("Starting logging");

  // initialize some variables for the buffers
  saveidx = 0;   // start saving at beginning of buffer
  savebuffnum = 0;  // start saving in dbuff0
  writebuffnum = -1;  // indicates no buffer ready yet
  //  start the interval timer to begin logging
  filestartmilli = millis();
  byteswritten = 0;
#ifdef USE_logtime
  logTime = 0;
#else
  if ( logging == 1 ) {
    Serial.println("PSRAM DIRECT _isr() logging");
    ADCTimer.begin(ADCChore, 1000000 / SAMPLERATE); //begin() expects timer period in microseconds
  }
  else if ( logging == 2 ) {
    Serial.println("PSRAM eRAM _isr() logging");
    ADCTimer.begin(ADCChore_eRAM, 1000000 / SAMPLERATE); //begin() expects timer period in microseconds
  }
#endif

}

void StopLogging(void) {
  if ( 0 == logging ) return;
  Serial.println("Stopping logging");
  logging = 0;
#ifdef USE_logtime
  logTime = 0;
  if (DEBUGPRINT) Serial.println("eMicros Log halted");
#else
  ADCTimer.end();
  if (DEBUGPRINT) Serial.println("ADCTimer halted");
#endif
  delay(10);
  writebuffnum = -1;
  Serial.printf("%lu KBytes written to file.\n", byteswritten / 1024);
  // in the interest of simplicity, we ignore any partial buffer at the end
}

void readArray (uint32_t ramAddr, uint32_t length, uint8_t *data)
{
  uint32_t ii;
  uint8_t *ptrERAM = (uint8_t *)(ramAddr);

  //uint32_t timenow = micros();
  for ( ii = 0; ii < length; ii++ ) {
    data[ii] = ptrERAM[ii];
  }
  //Serial.printf("Read (us): %d\n", micros()-timenow);
  //Serial.printf("read @%06X: ", ramAddr);
  //for (uint32_t i=0; i < length; i++) Serial.printf(" %02X", *(((uint8_t *)data) + i));
  //Serial.printf("\n");
  //Serial.printf("rd @%08X: ", (uint32_t)ptrERAM);
  //for (uint32_t i=0; i < length; i++) Serial.printf(" %02X", ptrERAM[i]);
  //Serial.printf("\n");
}

void writeArray (uint32_t ramAddr, uint32_t items, uint8_t values[])
{ 
  uint32_t ii;
  uint8_t *ptrERAM = (uint8_t *)(ramAddr);
  
  //Serial.printf("write @%06X:\n", ramAddr);
  //for (uint32_t i=0; i < items; i++) Serial.printf(" %02X", *(((uint8_t *)values) + i));
  //Serial.printf("\n");
  //uint32_t timenow = micros();
  for ( ii = 0; ii < items; ii++ ) {
    ptrERAM[ii] = values[ii];
  }
  //Serial.printf("Write (us): %d\n", micros()-timenow);

}

void writeLong(uint32_t ramAddr, uint32_t value)
{
  uint8_t *buffer = reinterpret_cast<uint8_t *>(&value);
  writeArray(ramAddr, 4, buffer);
  
}

void readLong(uint32_t ramAddr, uint32_t *value)
{
  uint8_t buffer[4];
  readArray(ramAddr, 4, buffer);
  *value = *reinterpret_cast<uint32_t *>(buffer);

}
This is what I am getting:
Code:
Starting logging

PSRAM eRAM _isr() logging

		 0 FULL e @ 16384 sbuff>70054000 
 	 BUFF at 70050000
 	 HIDE overWrap of 5  <<<<< 
skipped 6	1, 6, 70050060, 0	 	 kk==6  ????
 	 HIDE firstWrap of 7  <<<<< 
	DONE 1023 >> 128, 1023, 70053FF0, 0
0] 2048.60 mSec fill [lp#5290332] 	Writing dbuff0 to data file.  tmilli =  0  took   0.59 mSec
		 1 FULL e @ 16384 sbuff>70094000 
 	 BUFF at 70090000
	DONE 1023 >> 2176, 17407, 70093FF0, 1
1] 2047.75 mSec fill [lp#5290201] 	Writing dbuff1 to data file.  tmilli =  2048  took   0.35 mSec
		 0 FULL e @ 16384 sbuff>70054000 
 	 BUFF at 70050000
	DONE 1023 >> 4224, 33791, 70053FF0, 0
0] 2048.12 mSec fill [lp#5290333] 	Writing dbuff0 to data file.  tmilli =  4096  took   0.49 mSec
		 1 FULL e @ 16384 sbuff>70094000 
 	 BUFF at 70090000
	DONE 1023 >> 6272, 50175, 70093FF0, 1
1] 2047.81 mSec fill [lp#5290201] 	Writing dbuff1 to data file.  tmilli =  6144  took   0.32 mSec
		 0 FULL e @ 16384 sbuff>70054000 
 	 BUFF at 70050000
	DONE 1023 >> 8320, 66559, 70053FF0, 0
0] 2048.18 mSec fill [lp#5290332] 	Writing dbuff0 to data file.  tmilli =  8192  took   0.51 mSec
Stopping logging
 
Just back a bit - using post #369 code as new V3 base here. SublimeText has started taking 'TAB' and pick a new word/spelling - else went to esle ????

Code Compare ::
> Odd change to lastB=0 to '5'- when it is set on entry? :)
> Cool - I put back the ADCChore_eRAM() indexing properly and it stayed
> Sample rate still dies here at 8,000 and 4,000 and 2,000 - but not at 1,000 ??? _isr() triggers some failure?
> The change to " BUFFSIZE 8192*2 " misses the break boundary and always worked before - that is why this odd number was chosen - it broke PSRAM but fit in RAM1+RAM2 :: BUFFSIZE 9190*2

Something odd - moved the start address HIGHER and reduced the buffer size so it would cross the same boundary xxx50000 + 0x4000 :: NO ERRORS
Something magical about that boundary when crossed at SPEED?

And using eRAM access works it seems - so that access method keeping something straight in the process?

Oh and loop speed at 4000 sample rate shows similar! eRAM at 5.299M and DIRECT at 5.344M loops per second - but shows FAIL with 'r'.
 
Code Compare ::
> Odd change to lastB=0 to '5'- when it is set on entry? -----> I was wondering how it got there myself. I didn't touch that one since its set later as you said.
> Cool - I put back the ADCChore_eRAM() indexing properly and it stayed ----> actually works either way with the mods when I tested it.
> Sample rate still dies here at 8,000 and 4,000 and 2,000 - but not at 1,000 ??? _isr() triggers some failure? ----> with v2 and the p369 both work at 8K no problem. Have a v3 myself that combines the two as well have to go give it a try.
> The change to " BUFFSIZE 8192*2 " misses the break boundary and always worked before - that is why this odd number was chosen - it broke PSRAM but fit in RAM1+RAM2 :: BUFFSIZE 9190*2 ----> ah ok didn't realize why it was set at 9190 - will but it back. I just changed to be a multiple of 1K and divisible by 16 so a whole struct wouldn't try getting put where it didn't belong.

Oh and loop speed at 4000 sample rate shows similar! eRAM at 5.299M and DIRECT at 5.344M loops per second - but shows FAIL with 'r'. -----> strange have to look again thought it was working for me.

EDIT: @defragster. Here is my version 3 (attaching as a zip) PSRAM seems to be working at 20k samplerate - using writeArray. 'r' and 'R' pass with 's' option. 'r' with 'f' option works without skips starting at 4k. 'R' no skips at all speeds and wheter 'f or s'.

Oh, buffersize put back to 9190*2

EDIT2: Got curious about the readArray and writeArray times so I did a timing on the example sketch StructReadWrite.ino and:
Code:
Starting...

Struct Size: 1072
hardware initialized
ERAM ID: 0D 5D 5F FF FF EE BC 48
at 0x 7000000
Device found!

0.02800000ms   (setup struct and writeArray time)
...... ...... ......
0.02300000ms   (readArray time for struct size)

...... ...... ......
Data_0: true
Data_1: 1.3574999571
Data_2: 314159
Data_3: 142
Data_4: 
Data_5: The Quick Brown Fox
 

Attachments

  • DataloggerPSRAM329v3-200511a.zip
    4 KB · Views: 58
Last edited:
T4.1 odyssey

OK, I have still to wait some days to receive my T4.1
(SF seems to be a big attractor, or black hole)

May 10, 2020, 11:41 am
Departed
SAN FRANCISCO, UNITED STATES
Your item departed a transfer airport in INTERNATIONAL, SAN FRANCISCO, UNITED STATES on May 10, 2020 at 11:41 am. The item is currently in transit to the destination.

May 9, 2020, 10:52 pm
Arrived
SAN FRANCISCO, UNITED STATES

April 24, 2020, 8:00 pm
Processed Through Regional Facility
SAN FRANCISCO CA INTERNATIONAL DISTRIBUTION CENTER

April 24, 2020, 8:38 am
Departed USPS Regional Facility
SAN FRANCISCO CA INTERNATIONAL DISTRIBUTION CENTER

April 24, 2020, 8:38 am
Arrived at Regional Facility
SAN FRANCISCO CA INTERNATIONAL DISTRIBUTION CENTER

April 23, 2020, 8:17 pm
Arrived at USPS Regional Facility
SAN FRANCISCO CA INTERNATIONAL DISTRIBUTION CENTER

April 23, 2020, 7:54 pm
Departed USPS Regional Facility
SAN FRANCISCO CA DISTRIBUTION CENTER

April 23, 2020, 5:08 pm
Arrived at USPS Regional Facility
SAN FRANCISCO CA DISTRIBUTION CENTER

April 23, 2020, 4:35 pm
Departed USPS Regional Facility
SAN FRANCISCO CA NETWORK DISTRIBUTION CENTER

April 23, 2020, 4:11 pm
Arrived at USPS Regional Facility
SAN FRANCISCO CA NETWORK DISTRIBUTION CENTER

April 23, 2020
In Transit to Next Facility

April 22, 2020, 11:48 am
Departed USPS Facility
PORTLAND, OR 97215

April 22, 2020, 8:48 am
Arrived at USPS Facility
PORTLAND, OR 97215

April 22, 2020, 7:33 am
Accepted at USPS Origin Facility
SHERWOOD, OR 97140

April 21, 2020, 7:25 pm
Shipping Label Created, USPS Awaiting Item
SHERWOOD, OR 97140
 
I'm a bit sad about these international packages getting delayed. I really wanted you to get to play with the 4.1 beta before the official release - which is coming soon....
 
@WMXZ - Sounds almost as bad as my ordering a display (RA7786) from BuyDisplay on 4/13 and using the default shipping. Shipped 4/15.
Last update on shipping: 2020-04-17 22:40Shenzhen, delivered to air transport

Contacted BuyDisplay on 4/29 and they said, shipping is slower right now... Wait a few more weeks... If I need it faster, I could order another one and ship DHL...

Luckily for me shipments from PJRC are a lot quicker to where I am :D
 
Slow ship of Beta T_4.1 and other is not nice.

DHL worked from BuyDisplay/China in 4 days (for $25) a Sat order delivered following Thurs 4/30. Got parts for external power ( USB Micro breakout ) and 2x20 PCB sockets just haven't made time to assemble yet with so much sun.
 
Back
Top