Project: SPI_MSTransfer

Ok. Up to 260K and still no errors or OT's. Think it works :) Sorry, don't have a LC to test with :)

I have one on my desk with a breadboarded T_3.6 - but the wires I had were too short to connect - so it is waiting my trip downstairs to get 5 pieces of wire :(
 
Been using up all my short wires on these projects, think I have enough maybe for one more set up - no more T3.5's though. Only have T3.6's left :)
 
rPi can get to 64 Mhz - but not in the stock support list - saw that yesterday looking for valid MIN speeds to see if there was a reason slow speed was failing.

I have spools of wire downstairs - and cheapo premade 4" and 6" wires ( a bunch right beside me ) - but I tried a set of short clip&pin wires and the clip fell off so I set it aside ... decided sleep and the other test were higher priority.

I didn't look at github yet? Can we at least do the default first edit for "if ( spi_bus_speed > 8000000 ) _delay_before_deassertion = 0;" so we don't need to have local copies with edits as changes come along? No added params anywhere until the final CLASS interface is resolved.
 
indeed that sounds ok

using this instead:

Code:
if ( spi_bus_speed >[COLOR="#FF0000"]=[/COLOR] 8000000 ) _delay_before_deassertion = 0;

EDIT, testing at 8mhz, it is "slightly" picky, lets say intermittant, it's working with a "5" value

EDIT2, 12MHz seems to be running fine at 0
 
Last edited:
Oh. Forgot to mention you probably should delete the old examples from the repository. If you try and use them you will probably get a ton of errors at the slower speeds - or just put a note with the limitations :)
 
you shouldnt get errors with old ones, default is 25 unless >= 12mhz, the code should get rid of those errors i would imagine, the timing code is internal, not part of user sketch, wait! OT _time yes :)

commits made for >= 12MHz shifts to 0, otherwise 25
 
The tvMaster.ino is ready to go, but the OLD other master.ino with get OT's unless it gets the same fix!

I can do a PULL if you don't make it right TOny

That OLD other MASTER could be deleted or re-written to be a more common example - different from tvMaster/tvSlave.
 
Modified tvSlave to count F&F's and pinToggle per second - after the '[' I am getting 480 F&F and 10 pinToggle:

57388.00, #, #, #, #, #, #, #, #, #, #, #,15008,0 [480 ,10

I have the Master sending >1 millis above and changed to >=1 and I get this:
47016.00, #, #, #, #, #, #, #, #, #, #, #,166176,1 [950 ,10

Master is sending out the #60 F&F mixed with the #55 TViewer full text as before at the 1::25 rate, the #55's are not part of the count value before the '['.

These will indicate when the Master expected counts don't arrive. The pinToggle count will drop first because of the way it triggers on the Master.

Will get the latest GitHub later and test and upload this change for a PULL another request.
 
Updated my Defragster/SPI_MSTransfer-1 and did a tonton81 pull request for the TV samples.

Tony - your last update is working well! Had it running at 30 MHz. Just dropped to SPI 3 MHz and the F&F time is 336 uS and it is keeping up with the 950 F&F and (+50 #55's) 10 PinToggle with T_3.6 to T_3.1. The tvSlave is detecting 'DIFFS' though.
<edit> they were handled silently - as was desired with F&F! Rate was maybe 100 per 100,000? Scrolling too fast to see.

Dropped the tvMaster send to 2ms instead of 1ms - and no errors - so Slave was discarding some when too fast???:
> S >> 59636.00, #, #, #, #, #, #, #, #, #, #, #,245943,0 [480 ,10
> M >> F&F (OT=0) OT_CALC==1000 micros() _time==336

<edit>
Still no errors at 3 MHz with reduced F&F rate - :
31424.00, #, #, #, #, #, #, #, #, #, #, #,1360410,0 [480 ,10
 
Last edited:
Tony: for slower speeds - would there be away to do an extra NULL transfer16()? That would hold the CD line high for the last required transfer - no matter the speed?

Call it a STOP_WORD: All the needed bytes for the CRC to work would be present as long as that NULL stop_word were ignored if captured or missed? Maybe even a Transfer8() if your logic can handle it would take half the time for a more efficient STOP_BYTE.

The ~100 byte transfer takes 336 uS at 3 Mhz - so that extra 2 bytes would add 7 uS instead of an arbitrary 25 uS? Even if always done - at 30 MHz it would be under 1 uS.

The T3.6>3.1 at 3 MHz SPI - NO ERRORS : 17956.00, #, #, #, #, #, #, #, #, #, #, #,5343886,0 [480 ,10
 
Can;t do 8 as the slave register waits for a 16 bit transfer, setting it to 8 might break things

the "missing" items are not a problem from MST, there is actually a buffering issue (not with the ring arrays) with the array circular array buffer. every single function works perfectly for a ring buffer, however, im doing some testing on the array version, it seems to be queueing to _sometimes_ same array positions that are in queue only at certain times, im working on this, the issue seems to be when adding/removing, when the counter overlaps, it requeues and overrides an array slot that isnt dequeued yet, therefore, theres 2 dequeues gonna happen for the same bank

ex:
Code:
  uint8_t bufy[6] = { 0, 1, 2, 3, 4, 5 };
  uint8_t bufy1[6] = { 6, 7, 8, 9, 10, 11 };
  uint8_t bufy2[6] = { 12, 13, 14, 15, 16, 17 };
  uint8_t bufy3[6] = { 18, 19, 20, 21, 22, 23 };
  uint8_t bufy4[6] = { 24, 25, 26, 27, 28, 29 };
  uint8_t bufy5[6] = { 30, 31, 32, 33, 34, 35 };
  uint8_t bufy6[6] = { 36, 37, 38, 39, 40, 41 };
  uint8_t bufy7[6] = { 42, 43, 44, 45, 46, 47 };
  uint8_t bufy8[6] = { 48, 49, 50, 51, 52, 53 };
  t.push_back(bufy, 6);
  t.push_back(bufy1, 6);
  t.push_back(bufy2, 6);
  t.push_back(bufy3, 6);
  t.push_back(bufy4, 6);
  t.push_back(bufy5, 6);
  t.push_back(bufy6, 6);
  t.push_back(bufy7, 6);
  t.push_back(bufy8, 6);
  t.push_back(bufy8, 6);
  t.push_back(bufy1, 6);
  t.push_back(bufy1, 6);
  t.push_front(bufy2, 6);
  t.push_front(bufy1, 6);
  t.push_front(bufy1, 6);

Output:
Code:
----------------------
6 5 4 4 5 6 7 0 
Q Size: 8

The increment counter is reset, while pushing to front, the counter works, but theres duplicate dequeues
It's probably not seen by lower speeds because the data is dequeued faster than it could requeue, which means we're filling the buffer too fast, this is why a bigger buffer would matter
I need more play time with it

Maybe an idea, we fill the ring buffer with the queue size as values, so 10,6 would write 1,2,3,4,5,6,7,8,9,0 to the ring buffer for the 6 byte array version, but, instead of erase/add the values, the head and tail can move up and down the "read-only" ring buffer, while only the array buffer is the only one thats written. Therefore, I THINK.. it would work based on the read-only index?
ex: if the head's position returns value of 2, if we "push_front", the head should go back -1 and return 1 (without popping the ring buffer!). at that point, we have the user buffer memmoved to array #1.
what you think?

EDIT, I see what you mean, we create a transfer() function for 8 bit data wide, but actually shifts the bytes together to send them as 16 bytes while saving dataspace, understood, ill work on that after

also, whats weird is doing all push_back's dont have this issue, only pushing to front does, but MST doesnt use push_front, so it shouldnt be a problem for MST
 
Last edited:
This is looking good: (debug mode with pop_front testing:

Code:
----------------------
Initialized ring buffer: 0 1 2 3 4 5 6 7 
Q Size: 5
7 0 1 2 3 
DONE
Q Size: 6
6 7 0 1 2 3 
DONE
Q Size: 7
5 6 7 0 1 2 3 
DONE
Q Size: 8
4 5 6 7 0 1 2 3 
DONE
Q Size: 8
3 4 5 6 7 0 1 2 
DONE
Q Size: 8
2 3 4 5 6 7 0 1 
DONE

implementation im defining is initial ring buffer is initialized of values between 0 -> max, and remained in read-only state afterwards;
the head and tail move accross the ring buffer as needed, and it's value is used in the multidimensional array as the index of the row, while only the column (array) is written
 
ok, theres been a been a big change in the circular array handling of the library, it was only working "by accident", unintentionally, making it seem good.
The new version doesnt use a incrementing array positioner, instead, it uses an initialized _cbuf with values 0->max, and the head and tail move accross it feeding that value as an index for _cabuf
I did alot of manual testing with the methods and they seem to be working "properly" now

I would like some testers on this, but it's working on SPI_MST currently, I'll provide a demo sketch for testing the CA arrays manually
Code:
[ATTACH]13379._xfImport[/ATTACH]


BELOW HERE IS FOR TESTING BUFFER ARRAYS MANUALLY, DO NOT USE WITH MST (the prints overwhelm the slave!)
and if anyone wants to test manually, heres a few sample code i been playing with, and the same library with hardcoded debugging for testing, all the debug is stripped out of the test file, only backup file is enabled
Debugging enabled:
Code:
[ATTACH]13380._xfImport[/ATTACH]
Code:
#include "circular_buffer.h"

Circular_Buffer<uint16_t, 2048> cb;
Circular_Buffer<uint16_t, 4> cb2;
Circular_Buffer<uint32_t, 16> cb3;
Circular_Buffer<uint16_t, 16> cb4;

Circular_Buffer<uint32_t, 32, 250> print_test;



//Circular_Buffer<uint8_t, 64> c5;



void setup() {
  Serial.begin(1);
  while ( !Serial);
  delay(2400);
  Circular_Buffer<uint8_t, 64> c5;
  Serial.println("----------------------");


  Circular_Buffer<uint8_t, 8, 6> t;
  uint8_t bufy[6] = { 0, 1, 2, 3, 4, 5 };
  uint8_t bufy1[6] = { 6, 7, 8, 9, 10, 11 };
  uint8_t bufy2[6] = { 12, 13, 14, 15, 16, 17 };
  uint8_t bufy3[6] = { 18, 19, 20, 21, 22, 23 };
  uint8_t bufy4[6] = { 24, 25, 26, 27, 28, 29 };
  uint8_t bufy5[6] = { 30, 31, 32, 33, 34, 35 };
  uint8_t bufy6[6] = { 36, 37, 38, 39, 40, 41 };
  uint8_t bufy7[6] = { 42, 43, 44, 45, 46, 47 };
  uint8_t bufy8[6] = { 48, 49, 50, 51, 52, 53 };
  t.push_back(bufy, 6); // 0
  t.push_back(bufy1, 6); // 6
  t.push_back(bufy2, 6); // 12
  t.push_back(bufy3, 6); // 18
  t.push_back(bufy4, 6); // 24
  t.push_back(bufy5, 6); // 30
  t.push_back(bufy6, 6); // 36
  t.push_back(bufy7, 6); // 42
  t.push_back(bufy8, 6); // 48
  t.push_back(bufy, 6); // 0
  t.push_back(bufy1, 6); // 6
  t.push_back(bufy2, 6); // 12
  t.push_back(bufy3, 6); // 18
  t.push_back(bufy, 6); // 0
  t.push_front(bufy, 6); // 0
  t.push_front(bufy1, 6); // 6
  t.push_back(bufy, 6); // 12
  bufy[0] = 66;
  t.push_back(bufy, 6); // 66
    t.push_back(bufy, 6); // 0
    t.push_front(bufy1, 6); // 6
  return;

  Serial.println("myBuf: ");
  uint8_t mybuf[6], _size = t.size();
  for ( uint8_t j = 0; j < _size ; j++ ) {
    t.pop_front(mybuf, 6);
    for ( uint8_t i = 0; i < 6; i++ ) {
      Serial.print(mybuf[i]); Serial.print(" ");
    } Serial.println();
  }
  //return;
  int tsize = t.size();
  for ( uint8_t i = 0; i < tsize; i++ ) {
    //Serial.print(t.peek(i)); Serial.print(" ");
    for ( uint8_t j = 0; j < 6; j++ ) {
      Serial.print(t.front()[j], DEC); Serial.print(" ");
    } Serial.println();
    t.pop_front();
  } Serial.println();
  return;
  t.pop_front();
  t.pop_front();
  t.push_front(bufy3, 6);



  Serial.println(t.back()[0]);
  Serial.println(t.back()[1]);
  Serial.println(t.back()[2]);
  Serial.println(t.back()[3]);
  Serial.println(t.back()[4]);
  Serial.println(t.back()[5]);
  return;
  //  t.push_back(bufy8, 6);
  //  t.push_back(bufy1, 6);
  //  t.push_back(bufy1, 6);
  //  t.push_back(bufy2, 6);
  //  t.push_back(bufy1, 6);
  //  t.push_front(bufy1, 6);
  //  t.push_front(bufy1, 6);
  //  t.pop_front();
  t.push_front(bufy, 6);
  t.push_front(bufy1, 6);
  t.push_front(bufy2, 6);
  t.push_front(bufy3, 6);
  t.push_front(bufy4, 6);
  t.push_front(bufy5, 6);
  //  t.push_back(bufy, 6);
  //  t.push_back(bufy, 6);







  return;


  for ( uint16_t i = 0; i < tsize; i++ ) {
    Serial.print(t.peek(i)); Serial.print(" ");
  } Serial.println();


  uint8_t bufa[6] = { 18, 44, 20, 77, 9, 21 };
  t.match(bufa, 6, 0, 5, 2);


  return;
  for ( uint16_t i = 0; i < tsize; i++ ) {
    Serial.print(t.peek(i)); Serial.print(" ");
  } Serial.println();


  return;

  for ( uint8_t i = 0; i < tsize; i++ ) {
    Serial.print(t.peek(i)); Serial.print(" ");
    for ( uint8_t j = 0; j < 6; j++ ) {
      Serial.print(t.front()[j], DEC); Serial.print(" ");
    } Serial.println();
    t.pop_front();
  } Serial.println();

  return;

  Serial.print("Size: "); Serial.println(t.size());
  //  int tsize = t.size();
  for ( uint8_t i = 0; i < tsize; i++ ) {
    //    Serial.print("Loop Size: "); Serial.println(t.size());
    for ( uint8_t j = 0; j < 6; j++ ) {
      Serial.print(t.front()[j], DEC); Serial.print(" ");
    } Serial.println();
    t.read();
  }





  //  c5.print("Hello SPI_MSTransfer, ");
  //  c5.print("from ");
  //  c5.println("tonton81");
  //  while ( c5.size() > 0 ) {
  //    Serial.print((char)c5.read());
  //  }
  //  Serial.println("Proof the newline was carried into queue");
  return;


  //  for ( uint16_t i = 0; i < 34; i++ ) c5.write(i);
  //  while ( c5.size() > 0 ) {
  //    Serial.println(c5.read());
  //  } Serial.println("OK");
  c5.write(0x88);
  c5.write(0x77);
  c5.write(0x66);
  c5.write(0x55);
  c5.pop_back();
  c5.write(0x12);
  c5.write(0x34);
  Serial.println(c5.peek(2), HEX);

  Serial.println("--------------------------------------");
  uint8_t pb[4] = { 0 };
  c5.readBytes(pb, 4);
  for ( int i = 0; i < 4; i++ ) {
    Serial.println(pb[i], HEX);
  } Serial.println("OK");
  while ( c5.size() > 0 ) {
    Serial.println(c5.read(), HEX);
  } Serial.println("OK");



  return;

  print_test.print("Hello World");
  print_test.print("  ");
  print_test.println("Teensy here!");
  while ( print_test.size() > 0 ) {
    Serial.print((char)print_test.read());
  } Serial.println("OK");


  //  return;

  uint16_t testBuf[100];
  for ( uint16_t i = 0; i < 100; i++ ) testBuf[i] = i;
  uint32_t time = micros();

  cb.write(testBuf, 100);
  //  uint16_t myBuf2[] = { 1, 2, 3, 4, 5 };
  //  cb.push_front(myBuf2, 5);
  Serial.print(micros() - time);
  Serial.print("Size: "); Serial.println(cb.size());
  uint16_t size = cb.size();
  for ( uint16_t i = 0; i < size; i++ ) Serial.println(cb.read());
  //return;

  cb.write(0x1111);
  cb.write(0x1112);
  cb.write(0x1113);
  cb.write(0x1114);
  cb.write(0x1115);
  cb.push_front(0x85);
  cb.push_back(0x33);
  cb.push_front(0x66);
  uint16_t myBuf[] = { 1, 2, 3, 4, 5 };
  cb.push_front(myBuf, 5);
  Serial.print("Available: ");  Serial.println(cb.size());
  while ( cb.size() > 0 ) {
    Serial.println(cb.pop_front(), HEX);
  }


  Serial.println("----------------------");
  cb2.write(0x8807);
  cb2.write(6);
  cb2.write(0x2113);
  cb2.write(0x2114);
  cb2.write(0x2115);
  cb2.write(0x2116);
  cb2.write(0x2117);
  cb2.write(0x2118);
  cb2.push_back(0x2119);
  Serial.print("Available: ");  Serial.println(cb2.size());

  Serial.println("Peekbytes:");
  uint16_t buf[6];
  Serial.print("Count: "); Serial.println(cb2.peekBytes(buf, 6));
  for ( uint16_t i = 0; i < 6; i++ ) {
    Serial.print(buf[i], HEX); Serial.print(" ");
  } Serial.println();

  Serial.print("Print FIFO: ");  Serial.println(cb2.size());
  while ( cb2.size() > 0 ) {
    Serial.println(cb2.peek(), HEX);
    Serial.println(cb2.read(), HEX);
  }




  cb3.write(0x10002111);
  cb3.write(0x10002112);
  cb3.write(0x10002113);
  cb3.write(0x10002114);
  cb3.write(0x10002115);
  cb3.write(0x10002116);
  cb3.write(0x10002117);
  cb3.write(0x10002118);
  cb3.write(0x10002119);
  cb3.write(0x10002110);



  Serial.print("Available: "); Serial.println(cb3.size());
  while ( cb3.size() > 0 ) {
    Serial.println(cb3.peek(), HEX);
    Serial.println(cb3.read(), HEX);
  }










  cb4.write(0x2113);
  cb4.write(0x2114);
  uint16_t buff[4] = { 'T', 'o', 'n', 'y' };
  cb4.push_front(buff, 4);
  cb4.push_back(buff, 4);
  cb4.write(0x2115);
  cb4.write(0x2116);

  Serial.print("cb4 Available: ");  Serial.println(cb4.size());

  Serial.println("Printout:");
  while ( cb4.size() > 0 ) {
    Serial.println(cb4.read(), HEX);
  }



}

uint16_t buffer_arrays[32][250];
Circular_Buffer<uint16_t, 16> cb_ba;
Circular_Buffer<uint16_t, 32, 250> ca;

void loop() {
  return;
  static uint32_t timer = millis() - 3000;
  if ( millis() - timer > 2000 ) {
    timer = millis();


    for ( uint16_t i = 0; i < 35; i++ ) {
      static uint16_t val = 0;
      uint16_t Buf[20];
      for ( uint16_t i = 0; i < 20; i++ ) Buf[i] = i + val;
      ca.write(Buf, 20);
      val += 20;
    }

    while ( ca.size() > 0 ) {
      for ( uint16_t i = 0; i < 20; i++ ) {
        Serial.print(ca.front()[i]); Serial.print(" ");
      } Serial.println();
      ca.pop_front();
    }
    while (1);


  }
}

if it's all good, ill clean it up for a merge

also, if all good, i can work on a Q list method for showing off whats in your array queues
mike, were you joking when you said qlist? should we call it list or qlist for method ? :p
 
Last edited:
Heres a nice example of iterating using back() and dumping to the buffer with NEW pop_back(buf,len) method

Code:
  Serial.print(t.back()[0]); Serial.print(" ");
  Serial.print(t.back()[1]); Serial.print(" ");
  Serial.print(t.back()[2]); Serial.print(" ");
  Serial.print(t.back()[3]); Serial.print(" ");
  Serial.print(t.back()[4]); Serial.print(" ");
  Serial.print(t.back()[5]); Serial.println(" ");

  uint8_t caf[6];
  t.pop_back(caf, 6);

  Serial.print(caf[0]); Serial.print(" ");
  Serial.print(caf[1]); Serial.print(" ");
  Serial.print(caf[2]); Serial.print(" ");
  Serial.print(caf[3]); Serial.print(" ");
  Serial.print(caf[4]); Serial.print(" ");
  Serial.print(caf[5]); Serial.println(" ");

  int __size = t.size();
  for ( int i = 0; i < __size; i++ ) {
    Serial.print(t.back()[0]); Serial.print(" ");
    Serial.print(t.back()[1]); Serial.print(" ");
    Serial.print(t.back()[2]); Serial.print(" ");
    Serial.print(t.back()[3]); Serial.print(" ");
    Serial.print(t.back()[4]); Serial.print(" ");
    Serial.print(t.back()[5]); Serial.println(" ");
    t.pop_back(caf, 6);
  }

output:
Code:
Queue list: 
6 7 8 9 10 11 
42 43 44 45 46 47 
48 49 50 51 52 53 
0 1 2 3 4 5 
6 7 8 9 10 11 
12 13 14 15 16 17 
0 1 2 3 4 5 
66 1 2 3 4 5 <--------------- last item of Q list

66 1 2 3 4 5 <--------------- ((t.back()[x])) these used the back iterator to go over the array elements
66 1 2 3 4 5 <--------------- this is the printout of caf buffer (t.pop_back(caf, 6);) where its actually pulled out the back of the queue
0 1 2 3 4 5  <--------------------here is where the remaining elements get pulled out and displayed from the for loop iterating over back() followed by a pop_back(buffer,len) to update the buffer
12 13 14 15 16 17 
6 7 8 9 10 11 
0 1 2 3 4 5 
48 49 50 51 52 53 
42 43 44 45 46 47 
6 7 8 9 10 11
 
Theres a new list() method now, it outputs the following stats:

Code:
Queue Size: 8, Index order: 6 7 0 1 2 3 4 5 
First Entry: 36 37 38 39 40 41 
Last Entry: 0 1 2 3 4 5 

Queue list: 
0) 36 37 38 39 40 41 
1) 42 43 44 45 46 47 
2) 48 49 50 51 52 53 
3) 0 1 2 3 4 5 
4) 6 7 8 9 10 11 
5) 12 13 14 15 16 17 
6) 18 19 20 21 22 23 
7) 0 1 2 3 4 5

of course, im using max 6 byte arrays with a queue size of 8
if however you choose 10 bytes length array and you fill only 6, the printout will print the last 4 bytes as garbage, which is normal, as it prints the entire "length" of the buffer array.
if theres enough interest, which i doubt, i could refactor the printout by dedicating the first byte of the array as the length parameter, so the actually buffer starts at position 1, this will remedy the extra garbage printout after the buffer, but probably not worth the hastle of adding

Example:
changing:
Code:
  Circular_Buffer<uint8_t, 8, 6> t;
to
Code:
  Circular_Buffer<uint8_t, 8, 10> t;

you would get:
Code:
Queue Size: 8, Index order: 6 7 0 1 2 3 4 5 
First Entry: 6 7 8 9 10 11 0 0 0 29 
Last Entry: 66 1 2 3 4 5 0 121 31 0 

Queue list: 
0) 6 7 8 9 10 11 0 0 0 29 
1) 42 43 44 45 46 47 0 64 114 0 
2) 48 49 50 51 52 53 61 0 32 1 
3) 0 1 2 3 4 5 136 144 1 0 
4) 6 7 8 9 10 11 0 0 0 137 
5) 12 13 14 15 16 17 32 249 255 255 
6) 0 1 2 3 4 5 6 255 31 36 
7) 66 1 2 3 4 5 0 121 31 0

then again, if you use 1k buffers, you'll get annoying stats :)

might be easy to implement:

example of push_back() modification:
before:
Code:
memmove(_cabuf[_cbuf[tail&(_size-1)]],buffer,length*sizeof(T));
after:
Code:
    _cabuf[_cbuf[tail&(_size-1)]][0] = length;
    memmove(_cabuf[_cbuf[tail&(_size-1)]]+1,buffer,length*sizeof(T));

Output:
Code:
Queue Size: 1, Index order: 0 
First Entry: 6 0 1 2 3 4 5 0 224 24 
Last Entry: 6 0 1 2 3 4 5 0 224 24 

Queue list: 
0) [COLOR="#FF0000"]6 0 1 2 3 4 5[/COLOR] 0 224 24

then we could iterate the list printout using [0] for the length

an easy modification for pop_back(buf,len):

Code:
memmove(&buffer[0],&_cabuf[(tail-1)&(_size-1)][COLOR="#FF0000"][1][/COLOR],length*sizeof(T));

EDIT, almost done conversion! 1st byte will be array length internally, the array pointers i pushed them forward so the user when he calls buf[0] he gets his actual array and not the length value

I will leave the peek() function accessible for that dedicated position.
if a user wants the REAL array length, peek(0) or peek() is sufficient enough to get it
Code:
uint8_t buf[t.peek()];
t.pop_front(buf,sizeof(buf));
first value of buf[0] will not be the "length" value, but the original array start position
 
Last edited:
With tips from KurtE I glanced and the Slave_isr() code indeed uses registers not found on the T_LC so it would need reworked.

T_3.x from SPI.cpp:
Code:
	uint16_t transfer16(uint16_t data) {
		port().SR = SPI_SR_TCF;
		port().PUSHR = data | SPI_PUSHR_CTAS(1);
		while (!(port().SR & SPI_SR_TCF)) ; // wait
		return port().POPR;
	}

T_LC from SPI.cpp:
Code:
	uint16_t transfer16(uint16_t data) {
		port().C2 = SPI_C2_SPIMODE;
		port().S;
		port().DL = data;
		port().DH = data >> 8;
		while (!(port().S & SPI_S_SPRF)) ; // wait
		uint16_t r = port().DL | (port().DH << 8);
		port().C2 = 0;
		port().S;
		return r;
	}
 
Ok here is my "smart" qlist implementation:

We start by queueing items:
Code:
  Circular_Buffer<uint8_t, 8, 10> t;  //[COLOR="#FF0000"] <-- queue of 10 array bytes[/COLOR]
  uint8_t bufy[6] = { 0, 1, 2, 3, 4, 5 };
  uint8_t bufy1[COLOR="#FF0000"][9][/COLOR] = { 6, 7, 8, 9, 10, 11, [COLOR="#FF0000"]55, 77, 88[/COLOR] }; <-[COLOR="#FF0000"]- we input a 9 length buffer to test[/COLOR]
  uint8_t bufy2[6] = { 12, 13, 14, 15, 16, 17 };
  uint8_t bufy3[6] = { 18, 19, 20, 21, 22, 23 };
  uint8_t bufy4[6] = { 24, 25, 26, 27, 28, 29 };
  uint8_t bufy5[6] = { 30, 31, 32, 33, 34, 35 };
  uint8_t bufy6[6] = { 36, 37, 38, 39, 40, 41 };
  uint8_t bufy7[6] = { 42, 43, 44, 45, 46, 47 };
  uint8_t bufy8[6] = { 48, 49, 50, 51, 52, 53 };
  t.push_back(bufy, 6); // 0
  t.push_back(bufy1, 9); // 6 [COLOR="#FF0000"]<-- we inject a 9 byte buffer into a 10 byte array[/COLOR]
  t.push_front(bufy8, 6);
  t.list();

the output:
Code:
----------------------
Queue Size: 3, Index order: 7 0 1 
First Entry: 48 49 50 51 52 53 
Last Entry: 6 7 8 9 10 11 [COLOR="#FF0000"]55 77 88[/COLOR] 

Queue list: 
0) 48 49 50 51 52 53 // 6 bytes
1) 0 1 2 3 4 5  // 6 bytes
2) 6 7 8 9 10 11 [COLOR="#FF0000"]55 77 88[/COLOR] // 9 bytes

no more garbage printouts, and the internal library knows the exact lengths of all the buffered queues!
 
With tips from KurtE I glanced and the Slave_isr() code indeed uses registers not found on the T_LC so it would need reworked.

T_3.x from SPI.cpp:
Code:
	uint16_t transfer16(uint16_t data) {
		port().SR = SPI_SR_TCF;
		port().PUSHR = data | SPI_PUSHR_CTAS(1);
		while (!(port().SR & SPI_SR_TCF)) ; // wait
		return port().POPR;
	}

T_LC from SPI.cpp:
Code:
	uint16_t transfer16(uint16_t data) {
		port().C2 = SPI_C2_SPIMODE;
		port().S;
		port().DL = data;
		port().DH = data >> 8;
		while (!(port().S & SPI_S_SPRF)) ; // wait
		uint16_t r = port().DL | (port().DH << 8);
		port().C2 = 0;
		port().S;
		return r;
	}

the master registers are not important, the slave ones are :) the LC can use master sketch because it uses core spi transfer16 method
 
the master registers are not important, the slave ones are :) the LC can use master sketch because it uses core spi transfer16 method

Indeed - that was in reference to the Slave_isr() - just showing the code behind the diff SPI use on the two ...
 
im getting 49/50uS with your TV demos with t3.6 @ 180mhz and t3.5 @ 168mhz using 30mhz spi and new circular_buffer library in test mode (ill only update github once tested and confirmed by you guys)
github version is unintentionally working due to a bug in the design using incremental array pattern
the new version uses a ruler type system, where the head & tail traverse the positions of the array bank index


View attachment cb_test.zip

Code:
&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
^LTF&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
^LTF&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
^LTF&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
^LTF&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
^LTF&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==49
^LTF&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
^LTF&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
^LTF&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==49
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
F&F (OT=14) OT_CALC==100  micros() _time==50
^LTF&F (OT=14) OT_CALC==100  micros() _time==50

Code:
47108.00, #, #, #, #, #, #, #, #, #, #, #,20123,0 [96 ,10
47120.00, #, #, #, #, #, #, #, #, #, #, #,20124,0 [96 ,10
47132.00, #, #, #, #, #, #, #, #, #, #, #,20125,0 [96 ,10
47144.000000,    0.0471,    0.0471,2701324.000000,2701381.250000,47149.0000,  217.1405,  217.1428,  217.1451,47153.0000,47154.0000,47155.0000
47156.00, #, #, #, #, #, #, #, #, #, #, #,20126,0 [96 ,10
47168.00, #, #, #, #, #, #, #, #, #, #, #,20127,0 [96 ,10
47180.00, #, #, #, #, #, #, #, #, #, #, #,20128,0 [96 ,10
47192.00, #, #, #, #, #, #, #, #, #, #, #,20129,0 [96 ,10
47204.00, #, #, #, #, #, #, #, #, #, #, #,20130,0 [96 ,10
47216.00, #, #, #, #, #, #, #, #, #, #, #,20131,0 [96 ,10
47228.00, #, #, #, #, #, #, #, #, #, #, #,20132,0 [96 ,10
47240.00, #, #, #, #, #, #, #, #, #, #, #,20133,0 [96 ,10
47252.00, #, #, #, #, #, #, #, #, #, #, #,20134,0 [96 ,10
47264.00, #, #, #, #, #, #, #, #, #, #, #,20135,0 [96 ,10
47276.00, #, #, #, #, #, #, #, #, #, #, #,20136,0 [96 ,10
47288.00, #, #, #, #, #, #, #, #, #, #, #,20137,0 [96 ,10
47300.00, #, #, #, #, #, #, #, #, #, #, #,20138,0 [96 ,10
47312.00, #, #, #, #, #, #, #, #, #, #, #,20139,0 [96 ,10
47324.00, #, #, #, #, #, #, #, #, #, #, #,20140,0 [96 ,10
47336.00, #, #, #, #, #, #, #, #, #, #, #,20141,0 [96 ,10
47348.00, #, #, #, #, #, #, #, #, #, #, #,20142,0 [96 ,10
47360.00, #, #, #, #, #, #, #, #, #, #, #,20143,0 [96 ,10
47372.00, #, #, #, #, #, #, #, #, #, #, #,20144,0 [96 ,10
47384.00, #, #, #, #, #, #, #, #, #, #, #,20145,0 [96 ,10
47396.00, #, #, #, #, #, #, #, #, #, #, #,20146,0 [96 ,10
47408.00, #, #, #, #, #, #, #, #, #, #, #,20147,0 [96 ,10
47420.00, #, #, #, #, #, #, #, #, #, #, #,20148,0 [96 ,10
47432.00, #, #, #, #, #, #, #, #, #, #, #,20149,0 [96 ,10
47444.000000,    0.0474,    0.0474,2718512.750000,2718570.000000,47449.0000,  217.8302,  217.8325,  217.8348,47453.0000,47454.0000,47455.0000
47456.00, #, #, #, #, #, #, #, #, #, #, #,20150,0 [96 ,10
47468.00, #, #, #, #, #, #, #, #, #, #, #,20151,0 [96 ,10
47480.00, #, #, #, #, #, #, #, #, #, #, #,20152,0 [96 ,10
47492.00, #, #, #, #, #, #, #, #, #, #, #,20153,0 [96 ,10
47504.00, #, #, #, #, #, #, #, #, #, #, #,20154,0 [96 ,10
47516.00, #, #, #, #, #, #, #, #, #, #, #,20155,0 [96 ,10
47528.00, #, #, #, #, #, #, #, #, #, #, #,20156,0 [96 ,10
47540.00, #, #, #, #, #, #, #, #, #, #, #,20157,0 [96 ,10
47552.00, #, #, #, #, #, #, #, #, #, #, #,20158,0 [96 ,10
47564.00, #, #, #, #, #, #, #, #, #, #, #,20159,0 [96 ,10
47576.00, #, #, #, #, #, #, #, #, #, #, #,20160,0 [96 ,10
47588.00, #, #, #, #, #, #, #, #, #, #, #,20161,0 [96 ,10
47600.00, #, #, #, #, #, #, #, #, #, #, #,20162,0 [96 ,10
47612.00, #, #, #, #, #, #, #, #, #, #, #,20163,0 [96 ,10
47624.00, #, #, #, #, #, #, #, #, #, #, #,20164,0 [96 ,10
47636.00, #, #, #, #, #, #, #, #, #, #, #,20165,0 [96 ,10
47648.00, #, #, #, #, #, #, #, #, #, #, #,20166,0 [96 ,10
47660.00, #, #, #, #, #, #, #, #, #, #, #,20167,0 [96 ,10
47672.00, #, #, #, #, #, #, #, #, #, #, #,20168,0 [96 ,10
47684.00, #, #, #, #, #, #, #, #, #, #, #,20169,0 [96 ,10
47696.00, #, #, #, #, #, #, #, #, #, #, #,20170,0 [96 ,10
47708.00, #, #, #, #, #, #, #, #, #, #, #,20171,0 [96 ,10
47720.00, #, #, #, #, #, #, #, #, #, #, #,20172,0 [96 ,10
47732.00, #, #, #, #, #, #, #, #, #, #, #,20173,0 [96 ,10
47744.000000,    0.0477,    0.0477,2735701.500000,2735758.750000,47749.0000,  218.5177,  218.5200,  218.5223,47753.0000,47754.0000,47755.0000
47756.00, #, #, #, #, #, #, #, #, #, #, #,20174,0 [96 ,10
47768.00, #, #, #, #, #, #, #, #, #, #, #,20175,0 [96 ,10
47780.00, #, #, #, #, #, #, #, #, #, #, #,20176,0 [96 ,10
47792.00, #, #, #, #, #, #, #, #, #, #, #,20177,0 [96 ,10
47804.00, #, #, #, #, #, #, #, #, #, #, #,20178,0 [96 ,10
47816.00, #, #, #, #, #, #, #, #, #, #, #,20179,0 [96 ,10
47828.00, #, #, #, #, #, #, #, #, #, #, #,20180,0 [96 ,10
47840.00, #, #, #, #, #, #, #, #, #, #, #,20181,0 [96 ,10
47852.00, #, #, #, #, #, #, #, #, #, #, #,20182,0 [96 ,10
47864.00, #, #, #, #, #, #, #, #, #, #, #,20183,0 [96 ,10
47876.00, #, #, #, #, #, #, #, #, #, #, #,20184,0 [96 ,10
47888.00, #, #, #, #, #, #, #, #, #, #, #,20185,0 [96 ,10
47900.00, #, #, #, #, #, #, #, #, #, #, #,20186,0 [96 ,10
47912.00, #, #, #, #, #, #, #, #, #, #, #,20187,0 [96 ,10
47924.00, #, #, #, #, #, #, #, #, #, #, #,20188,0 [96 ,10
47936.00, #, #, #, #, #, #, #, #, #, #, #,20189,0 [96 ,10
47948.00, #, #, #, #, #, #, #, #, #, #, #,20190,0 [96 ,10
47960.00, #, #, #, #, #, #, #, #, #, #, #,20191,0 [96 ,10
47972.00, #, #, #, #, #, #, #, #, #, #, #,20192,0 [96 ,10
47984.00, #, #, #, #, #, #, #, #, #, #, #,20193,0 [96 ,10
47996.00, #, #, #, #, #, #, #, #, #, #, #,20194,0 [96 ,10
48008.00, #, #, #, #, #, #, #, #, #, #, #,20195,0 [96 ,10
48020.00, #, #, #, #, #, #, #, #, #, #, #,20196,0 [96 ,10
48032.00, #, #, #, #, #, #, #, #, #, #, #,20197,0 [96 ,10
48044.000000,    0.0480,    0.0480,2752890.250000,2752947.500000,48049.0000,  219.2031,  219.2054,  219.2077,48053.0000,48054.0000,48055.0000
48056.00, #, #, #, #, #, #, #, #, #, #, #,20198,0 [96 ,10
48068.00, #, #, #, #, #, #, #, #, #, #, #,20199,0 [96 ,10
48080.00, #, #, #, #, #, #, #, #, #, #, #,20200,0 [96 ,10
48092.00, #, #, #, #, #, #, #, #, #, #, #,20201,0 [96 ,10
48104.00, #, #, #, #, #, #, #, #, #, #, #,20202,0 [96 ,10
48116.00, #, #, #, #, #, #, #, #, #, #, #,20203,0 [96 ,10
48128.00, #, #, #, #, #, #, #, #, #, #, #,20204,0 [96 ,10
48140.00, #, #, #, #, #, #, #, #, #, #, #,20205,0 [96 ,10
48152.00, #, #, #, #, #, #, #, #, #, #, #,20206,0 [96 ,10
48164.00, #, #, #, #, #, #, #, #, #, #, #,20207,0 [96 ,10
48176.00, #, #, #, #, #, #, #, #, #, #, #,20208,0 [96 ,10
48188.00, #, #, #, #, #, #, #, #, #, #, #,20209,0 [96 ,10
48200.00, #, #, #, #, #, #, #, #, #, #, #,20210,0 [96 ,10
48212.00, #, #, #, #, #, #, #, #, #, #, #,20211,0 [96 ,10
48224.00, #, #, #, #, #, #, #, #, #, #, #,20212,0 [96 ,10
48236.00, #, #, #, #, #, #, #, #, #, #, #,20213,0 [96 ,10
48248.00, #, #, #, #, #, #, #, #, #, #, #,20214,0 [96 ,10
48260.00, #, #, #, #, #, #, #, #, #, #, #,20215,0 [96 ,10
48272.00, #, #, #, #, #, #, #, #, #, #, #,20216,0 [96 ,10
48284.00, #, #, #, #, #, #, #, #, #, #, #,20217,0 [96 ,10
48296.00, #, #, #, #, #, #, #, #, #, #, #,20218,0 [96 ,10
48308.00, #, #, #, #, #, #, #, #, #, #, #,20219,0 [96 ,10
48320.00, #, #, #, #, #, #, #, #, #, #, #,20220,0 [96 ,10
48332.00, #, #, #, #, #, #, #, #, #, #, #,20221,0 [96 ,10
48344.000000,    0.0483,    0.0483,2770079.000000,2770136.250000,48349.0000,  219.8863,  219.8886,  219.8909,48353.0000,48354.0000,48355.0000
48356.00, #, #, #, #, #, #, #, #, #, #, #,20222,0 [96 ,10
48368.00, #, #, #, #, #, #, #, #, #, #, #,20223,0 [96 ,10
48380.00, #, #, #, #, #, #, #, #, #, #, #,20224,0 [96 ,10
48392.00, #, #, #, #, #, #, #, #, #, #, #,20225,0 [96 ,10
48404.00, #, #, #, #, #, #, #, #, #, #, #,20226,0 [96 ,10
48416.00, #, #, #, #, #, #, #, #, #, #, #,20227,0 [96 ,10
48428.00, #, #, #, #, #, #, #, #, #, #, #,20228,0 [96 ,10
48440.00, #, #, #, #, #, #, #, #, #, #, #,20229,0 [96 ,10
48452.00, #, #, #, #, #, #, #, #, #, #, #,20230,0 [96 ,10
48464.00, #, #, #, #, #, #, #, #, #, #, #,20231,0 [96 ,10
48476.00, #, #, #, #, #, #, #, #, #, #, #,20232,0 [96 ,10
48488.00, #, #, #, #, #, #, #, #, #, #, #,20233,0 [96 ,10
48500.00, #, #, #, #, #, #, #, #, #, #, #,20234,0 [96 ,10
48512.00, #, #, #, #, #, #, #, #, #, #, #,20235,0 [96 ,10
48524.00, #, #, #, #, #, #, #, #, #, #, #,20236,0 [96 ,10
48536.00, #, #, #, #, #, #, #, #, #, #, #,20237,0 [96 ,10
48548.00, #, #, #, #, #, #, #, #, #, #, #,20238,0 [96 ,10
48560.00, #, #, #, #, #, #, #, #, #, #, #,20239,0 [96 ,10
48572.00, #, #, #, #, #, #, #, #, #, #, #,20240,0 [96 ,10
48584.00, #, #, #, #, #, #, #, #, #, #, #,20241,0 [96 ,10
48596.00, #, #, #, #, #, #, #, #, #, #, #,20242,0 [96 ,10
48608.00, #, #, #, #, #, #, #, #, #, #, #,20243,0 [96 ,10
48620.00, #, #, #, #, #, #, #, #, #, #, #,20244,0 [96 ,10
48632.00, #, #, #, #, #, #, #, #, #, #, #,20245,0 [96 ,10
48644.000000,    0.0486,    0.0486,2787267.750000,2787325.000000,48649.0000,  220.5674,  220.5697,  220.5720,48653.0000,48654.0000,48655.0000
48656.00, #, #, #, #, #, #, #, #, #, #, #,20246,0 [96 ,10
48668.00, #, #, #, #, #, #, #, #, #, #, #,20247,0 [96 ,10
48680.00, #, #, #, #, #, #, #, #, #, #, #,20248,0 [96 ,10
48692.00, #, #, #, #, #, #, #, #, #, #, #,20249,0 [96 ,10
48704.00, #, #, #, #, #, #, #, #, #, #, #,20250,0 [96 ,10
48716.00, #, #, #, #, #, #, #, #, #, #, #,20251,0 [96 ,10
48728.00, #, #, #, #, #, #, #, #, #, #, #,20252,0 [96 ,10
48740.00, #, #, #, #, #, #, #, #, #, #, #,20253,0 [96 ,10
48752.00, #, #, #, #, #, #, #, #, #, #, #,20254,0 [96 ,10
48764.00, #, #, #, #, #, #, #, #, #, #, #,20255,0 [96 ,10

ignore the 14's, i was hot plug testing
 
I swapped that cb_test .h into my SPI_MST folder and both built Slave is online showing nothing and Master is just showing:

"FAIL_Res #1 RETRY...FAIL_Res #2 RETRY...FAIL_Res #3 RETRY...DBG: [S_CS 15] FAIL_RES #4 Tx ABORT. F&F (OT=0) OT_CALC==100 micros() _time==47"

That is my current TV examples that were just running ... bumped SPI 3 MHz to 30 MHz - no change ...
 
Back
Top