OPPS - that code points to DMAMEM not PSRAM EXTMEM.
And EXTMEM just moved ...
Those 'index' numbers were printing only to show that loop() is running and that the index is advancing under the ISR. And show how many are logged each 200ms.
The demo code shown (except for the BUGBUG: || 0 == idxFoo) will run and log and overwrite continuously until an INPUT triggers to stop the ISR. Assuming you have a way to configure a similar input as the threads start? Or another way to TIME since cutting was engaged?
Your code wouldn't trigger like that - as you know when the needed values are secure - but would need a similar method to stop the log indexing and overwriting the initial data of concern.
Something isn't "mathing" with the memory consumption? That example logging 16 bytes (4 DWORDS) will fault if more than 65535 groups are written???? That is only 1 MB when it should run to 8MB? The Pointer math or the way the pointer is created is wrong?
200 RPM is better as it will assure the PSRAM writes don't cause any slowdown as they pass through the cache and into physical PSRAM.
Thanks for the explanation. I need to figure out how to trigger this intelligently, as there's not a lot of spare memory. A simple way for me is to start when I touch the start button. But after the start, I have to physically engage the half nut lever, and that can take a random amount of time. A better way would be after start AND the carriage is moving - but that may take some time to debug. The log can stop automatically at some Z value, as that is easy to query.
About the memory, it's easy to mess this up, I've done it a lot!
Mem = 8MB [bytes], encoder is 4096 counts/revolution.
time between interrupts = 60/(RPM x 4096) = 60/(200 *4096) = 73.24 us
bytes saved = 32 (size of the struct). If saving uint32's that's 4 bytes/uint32, or 8 uint32's. (8 x sizeof(uint32_t) = 32)
Number of structs that can fit in 8MB = (8*1024*1024) / 32 = 262144.0
Time to write all these structs (assuming one is written every interrupt): = 262144 [structs] * 73.24us/[struct] = 19.2 sec
Rotations of the spindle in 19.2 s (@200 RPM) = 19.2/(60/200) = 64
Double check.
64 rotations * 4096 interrupts/rotation * 32 bytes/interrupt = 8388608 bytes = 8MB.
This is better than I expected, so this is good.
Spent about 1/2 hour doing some old school printing. When programs get too large, I need to lay it all out before me to figure out what to do. I'll figure it out on paper, mark it up, and have at it. If I had 4 more 4k monitors I could do it on screen, alas, I don't have space for that

.