Project: SPI_MSTransfer

I just had some coffee and was thinking that you could just put it in the SPI_MST_Transfer constructor, e.g.,
Code:
SPI_MSTransfer teensy_gpio = SPI_MSTransfer("Serial", SPI_MST_CS, &SPI_MST_BUS, SPI_SPEED, LC_Mode );

LC_Mode would then just be 1 for LC and 0 for T3.x. You could also then just default to 0 so for T3.x series it would then be:
Code:
SPI_MSTransfer teensy_gpio = SPI_MSTransfer("Serial", SPI_MST_CS, &SPI_MST_BUS, SPI_SPEED );
which is what we had.
 
We could do that, but how long we gonna load the constructor ?:p What if we need more items to stuff there?

or this?

Code:
[COLOR="#FF8C00"]void SPI_MSTransfer::LCmode(uint8_t reads, uint8_t writes) {
    LC_delays = (uint16_t)(reads << 8) | writes;
}[/COLOR]
uint16_t SPI_MSTransfer::_transfer16_write(uint16_t data) {
  (*(KINETISK_SPI_t *)_spi_port_memorymap).SR = SPI_SR_TCF;
  (*(KINETISK_SPI_t *)_spi_port_memorymap).PUSHR = data | SPI_PUSHR_CTAS(1);
  while (!((*(KINETISK_SPI_t *)_spi_port_memorymap).SR & SPI_SR_TCF)) ; // wait
  if ( [COLOR="#FF8C00"](uint8_t)LC_delays[/COLOR] ) delayMicroseconds( [COLOR="#FF8C00"](uint8_t)LC_delays[/COLOR] ); 
  return (*(KINETISK_SPI_t *)_spi_port_memorymap).POPR;
}
uint16_t SPI_MSTransfer::_transfer16_writeread(uint16_t data) {
  (*(KINETISK_SPI_t *)_spi_port_memorymap).SR = SPI_SR_TCF;
  (*(KINETISK_SPI_t *)_spi_port_memorymap).PUSHR = data | SPI_PUSHR_CTAS(1);
  while (!((*(KINETISK_SPI_t *)_spi_port_memorymap).SR & SPI_SR_TCF)) ; // wait
  if ([COLOR="#FF8C00"] LC_delays >> 8[/COLOR] ) delayMicroseconds([COLOR="#FF8C00"] LC_delays >> 8 [/COLOR]); 
  return (*(KINETISK_SPI_t *)_spi_port_memorymap).POPR;
}

Then in sketch:
Code:
teensy_gpio.LCmode(10,10);
teensy_gpio2.LCmode(10,10);

Set them both to 0 to disable.
 
Last edited:
That would work too. But is there a reason you would want to set 2 delays and just not make it one - not being difficult just trying to understand, i.e., teensy_gpio.LCmode(10) as opposed to 10,10?

Or, if not defined it defaults to LCmode(0,0)?
 
Not defined is set at 0,0
Code:
    volatile uint16_t       LC_delays = 0UL;
one delay is for writing without reading
the other delay is for the delay after write FOR reading
if you do LCMode(10) for example, only delay is added for read, not write

writes are default 0 unless specified:
Code:
    void            LCmode(uint8_t reads, uint8_t writes = 0);

I'd still like to poke into the slave code to see if I can push those slave register limits

EDIT: this is working also:
Code:
teensy_gpio.LCmode(0,5);
teensy_gpio2.LCmode(0,5);
slowing down the writes, reading doesnt seem to be having an issue so far...

this makes testing easier :)

heres the master ATM, gonna go play with the slave LC ISR

Code:
[ATTACH]13823._xfImport[/ATTACH]
 
Last edited:
Had to run out to the store, anyway retested:
1. T3.6/T3.5 all works no problem.
2. T3.5/LC all works no problem.

I am using my new master sketch for this, the one change I made was:
Code:
#if defined(TLC)
  teensy_gpio.LCmode(0,5);
  teensy_gpio2.LCmode(0,5);
  teensy_gpio2.onTransfer(myCallback);
#else
  teensy_gpio.LCmode(0,0);
  teensy_gpio.onTransfer(myCallback);
#endif

EDIT:
poke into the slave code to see if I can push those slave register limits
Good luck. I have faith in you - you did it once :)
 
cool, you dont need an else LCmode though, it's 0 by default

I'm working on the slave ISR and so far I can get F&F & toggling at 8MHz, but very very intermittant pause, no lockups though, still working on it
It is very finicky with ordering, and in some cases one order does not work in another area, so at least I got only 4 sections between F&F and toggling to tweak and see what goes next
 
I forgot to ask something - think we touched on it someplace - we can still use alternate pins for SPI0, I2C, etc ? Think the answer is yes if its supported.

EDIT: "LCmode though, it's 0 by default" Cool - fixed in my master :)

"It is very finicky with ordering," - guess that's the LC for you....
 
LCmode(0,0)
6MHz
500ms led toggling
no pauses

:eek:

still need to test stability before i go through editing the ENTIRE ISR again (more time to do! lol)

205uS is the time on master console

I stilll get intermittant pauses at 8MHz, but, can we assume the LC is only max 6 and 8 is too much?? :)

EDIT, at 100ms led toggling and 1ms F&F firing, we have slave:

Code:
[951 ,0

master:
Code:
_time==205

EDIT, I don't think LC can do 12MHz slave mode... 8-12mhz results in the exact time for f&f's, the time is only different when going below 8.....
If I set master to 20MHz, it still results in same times as 8MHz... (with obvious crashings)

before I go ahead and break things, this one can be tested, but ONLY for F&F and LED toggling, I didn't modify the rest of the ISR yet..
(ex. do NOT run events());

LCmode is not mandatory, but it's required to stop the slave from intermittantly counting errors :)

Code:
[ATTACH]13824._xfImport[/ATTACH]

Alright I edited the ISR down up until the FEATURES section, they will wait for now till I test a bit
but
6MHz, LCMode requires 10,10 (5 crashed when polling events() in tight loop)
It's not pausing anymore and running 8ms F&F's, tight events() loop, and 100ms led toggling...

Heres the update for testing:

Code:
[ATTACH]13825._xfImport[/ATTACH]

I will patch the rest of the "features" (remote UART,EEPROM,SPI,WIRE control) once this is confirmed stable, because editing the whole ISR takes alot of time

Also, don't go lower than 2ms F&F's, youll get DIFF errors of slave callbacks, you need 2 or HIGHER, (so LC can process the data)
 
Last edited:
BTW Mike, I changed your code a bit, you wernt counting the F&F time, you were counting the serial print time as well (adding to the time delay). Here's the correction:

Before:
Code:
    Serial.print("F&F (OT=");
    Serial.print( OverTime );
    Serial.print(")");
    _time = micros();

    __countB++;
    if ( __countB % 25 )
      teensy_gpio.transfer16((uint16_t *)MST_PrintVals, sizeof(MST_PrintVals) / 2, 60, 1); // DEBUGHACK output
    else
      teensy_gpio.transfer16((uint16_t *)MST_PrintVals, sizeof(MST_PrintVals) / 2, 55, 1);

    _time = micros() - _time;
    Serial.print(" OT_CALC==");
    Serial.print(OT_CALC);
    Serial.print("  micros() _time==");
    Serial.println(_time);
    if ( _time > OT_CALC ) OverTime++;

Now:
Code:
    Serial.print("F&F (OT=");
    Serial.print( OverTime );
    Serial.print(")");

    Serial.print(" OT_CALC==");
    Serial.print(OT_CALC);
    Serial.print("  micros() _time==");
    if ( _time > OT_CALC ) OverTime++;

    __countB++;
    _time = micros() - _time;
    if ( __countB % 25 )
      teensy_gpio.transfer16((uint16_t *)MST_PrintVals, sizeof(MST_PrintVals) / 2, 60, 1); // DEBUGHACK output
    else
      teensy_gpio.transfer16((uint16_t *)MST_PrintVals, sizeof(MST_PrintVals) / 2, 55, 1);
    Serial.println(_time);

Status before:
Code:
F&F (OT=1232) OT_CALC==500  micros() _time==665
F&F (OT=1233) OT_CALC==500  micros() _time==662
F&F (OT=1234) OT_CALC==500  micros() _time==662
F&F (OT=1235) OT_CALC==500  micros() _time==662
F&F (OT=1236) OT_CALC==500  micros() _time==662
F&F (OT=1237) OT_CALC==500  micros() _time==664
F&F (OT=1238) OT_CALC==500  micros() _time==661
F&F (OT=1239) OT_CALC==500  micros() _time==663
F&F (OT=1240) OT_CALC==500  micros() _time==662
F&F (OT=1241) OT_CALC==500  micros() _time==662
F&F (OT=1242) OT_CALC==500  micros() _time==662
F&F (OT=1243) OT_CALC==500  micros() _time==662
F&F (OT=1244) OT_CALC==500  micros() _time==663
F&F (OT=1245) OT_CALC==500  micros() _time==662
F&F (OT=1246) OT_CALC==500  micros() _time==661
F&F (OT=1247) OT_CALC==500  micros() _time==661
F&F (OT=1248) OT_CALC==500  micros() _time==661
F&F (OT=1249) OT_CALC==500  micros() _time==661
^LTF&F (OT=1250) OT_CALC==500  micros() _time==665
F&F (OT=1251) OT_CALC==500  micros() _time==662
F&F (OT=1252) OT_CALC==500  micros() _time==661
F&F (OT=1253) OT_CALC==500  micros() _time==661
F&F (OT=1254) OT_CALC==500  micros() _time==663
F&F (OT=1255) OT_CALC==500  micros() _time==662
F&F (OT=1256) OT_CALC==500  micros() _time==661
F&F (OT=1257) OT_CALC==500  micros() _time==661
F&F (OT=1258) OT_CALC==500  micros() _time==664
F&F (OT=1259) OT_CALC==500  micros() _time==662
F&F (OT=1260) OT_CALC==500  micros() _time==662
F&F (OT=1261) OT_CALC==500  micros() _time==663
F&F (OT=1262) OT_CALC==500  micros() _time==661
F&F (OT=1263) OT_CALC==500  micros() _time==662
F&F (OT=1264) OT_CALC==500  micros() _time==662
F&F (OT=1265) OT_CALC==500  micros() _time==662
F&F (OT=1266) OT_CALC==500  micros() _time==662
F&F (OT=1267) OT_CALC==500  micros() _time==664
F&F (OT=1268) OT_CALC==500  micros() _time==662
F&F (OT=1269) OT_CALC==500  micros() _time==662
F&F (OT=1270) OT_CALC==500  micros() _time==663
F&F (OT=1271) OT_CALC==500  micros() _time==665
F&F (OT=1272) OT_CALC==500  micros() _time==662
F&F (OT=1273) OT_CALC==500  micros() _time==662
F&F (OT=1274) OT_CALC==500  micros() _time==662
F&F (OT=1275) OT_CALC==500  micros() _time==663
F&F (OT=1276) OT_CALC==500  micros() _time==662
F&F (OT=1277) OT_CALC==500  micros() _time==663
F&F (OT=1278) OT_CALC==500  micros() _time==663
F&F (OT=1279) OT_CALC==500  micros() _time==662
F&F (OT=1280) OT_CALC==500  micros() _time==662
F&F (OT=1281) OT_CALC==500  micros() _time==663
F&F (OT=1282) OT_CALC==500  micros() _time==662
F&F (OT=1283) OT_CALC==500  micros() _time==662
F&F (OT=1284) OT_CALC==500  micros() _time==664
F&F (OT=1285) OT_CALC==500  micros() _time==663
F&F (OT=1286) OT_CALC==500  micros() _time==663
F&F (OT=1287) OT_CALC==500  micros() _time==663
F&F (OT=1288) OT_CALC==500  micros() _time==665
F&F (OT=1289) OT_CALC==500  micros() _time==662
F&F (OT=1290) OT_CALC==500  micros() _time==662
F&F (OT=1291) OT_CALC==500  micros() _time==662
F&F (OT=1292) OT_CALC==500  micros() _time==665
F&F (OT=1293) OT_CALC==500  micros() _time==663
F&F (OT=1294) OT_CALC==500  micros() _time==662
F&F (OT=1295) OT_CALC==500  micros() _time==662
F&F (OT=1296) OT_CALC==500  micros() _time==662
F&F (OT=1297) OT_CALC==500  micros() _time==664
F&F (OT=1298) OT_CALC==500  micros() _time==662
F&F (OT=1299) OT_CALC==500  micros() _time==662
^LTF&F (OT=1300) OT_CALC==500  micros() _time==662
F&F (OT=1301) OT_CALC==500  micros() _time==665
F&F (OT=1302) OT_CALC==500  micros() _time==662
F&F (OT=1303) OT_CALC==500  micros() _time==662
F&F (OT=1304) OT_CALC==500  micros() _time==662
F&F (OT=1305) OT_CALC==500  micros() _time==663
F&F (OT=1306) OT_CALC==500  micros() _time==662
F&F (OT=1307) OT_CALC==500  micros() _time==663
F&F (OT=1308) OT_CALC==500  micros() _time==662
F&F (OT=1309) OT_CALC==500  micros() _time==662
F&F (OT=1310) OT_CALC==500  micros() _time==664
F&F (OT=1311) OT_CALC==500  micros() _time==662
F&F (OT=1312) OT_CALC==500  micros() _time==662
F&F (OT=1313) OT_CALC==500  micros() _time==662
F&F (OT=1314) OT_CALC==500  micros() _time==664
F&F (OT=1315) OT_CALC==500  micros() _time==662
F&F (OT=1316) OT_CALC==500  micros() _time==662
F&F (OT=1317) OT_CALC==500  micros() _time==662
F&F (OT=1318) OT_CALC==500  micros() _time==665
F&F (OT=1319) OT_CALC==500  micros() _time==662
F&F (OT=1320) OT_CALC==500  micros() _time==662
F&F (OT=1321) OT_CALC==500  micros() _time==662
F&F (OT=1322) OT_CALC==500  micros() _time==665
F&F (OT=1323) OT_CALC==500  micros() _time==662
F&F (OT=1324) OT_CALC==500  micros() _time==662
F&F (OT=1325) OT_CALC==500  micros() _time==663
F&F (OT=1326) OT_CALC==500  micros() _time==663
F&F (OT=1327) OT_CALC==500  micros() _time==664
F&F (OT=1328) OT_CALC==500  micros() _time==661
F&F (OT=1329) OT_CALC==500  micros() _time==661
F&F (OT=1330) OT_CALC==500  micros() _time==662
F&F (OT=1331) OT_CALC==500  micros() _time==664
F&F (OT=1332) OT_CALC==500  micros() _time==661

Status now:
Code:
F&F (OT=792) OT_CALC==500  micros() _time==13
F&F (OT=793) OT_CALC==500  micros() _time==11
F&F (OT=794) OT_CALC==500  micros() _time==13
F&F (OT=795) OT_CALC==500  micros() _time==12
F&F (OT=796) OT_CALC==500  micros() _time==13
F&F (OT=797) OT_CALC==500  micros() _time==11
F&F (OT=798) OT_CALC==500  micros() _time==13
F&F (OT=799) OT_CALC==500  micros() _time==13
^LTF&F (OT=800) OT_CALC==500  micros() _time==13
F&F (OT=801) OT_CALC==500  micros() _time==12
F&F (OT=802) OT_CALC==500  micros() _time==13
F&F (OT=803) OT_CALC==500  micros() _time==13
F&F (OT=804) OT_CALC==500  micros() _time==12
F&F (OT=805) OT_CALC==500  micros() _time==11
F&F (OT=806) OT_CALC==500  micros() _time==13
F&F (OT=807) OT_CALC==500  micros() _time==13
F&F (OT=808) OT_CALC==500  micros() _time==11
F&F (OT=809) OT_CALC==500  micros() _time==13
F&F (OT=810) OT_CALC==500  micros() _time==13
F&F (OT=811) OT_CALC==500  micros() _time==13
F&F (OT=812) OT_CALC==500  micros() _time==11
F&F (OT=813) OT_CALC==500  micros() _time==13
F&F (OT=814) OT_CALC==500  micros() _time==13
F&F (OT=815) OT_CALC==500  micros() _time==13
F&F (OT=816) OT_CALC==500  micros() _time==11
F&F (OT=817) OT_CALC==500  micros() _time==13
F&F (OT=818) OT_CALC==500  micros() _time==13
F&F (OT=819) OT_CALC==500  micros() _time==12
F&F (OT=820) OT_CALC==500  micros() _time==11
F&F (OT=821) OT_CALC==500  micros() _time==13
F&F (OT=822) OT_CALC==500  micros() _time==13
F&F (OT=823) OT_CALC==500  micros() _time==12
F&F (OT=824) OT_CALC==500  micros() _time==12
F&F (OT=825) OT_CALC==500  micros() _time==13
F&F (OT=826) OT_CALC==500  micros() _time==13
F&F (OT=827) OT_CALC==500  micros() _time==11
F&F (OT=828) OT_CALC==500  micros() _time==13
F&F (OT=829) OT_CALC==500  micros() _time==13
F&F (OT=830) OT_CALC==500  micros() _time==13
F&F (OT=831) OT_CALC==500  micros() _time==11
F&F (OT=832) OT_CALC==500  micros() _time==12
F&F (OT=833) OT_CALC==500  micros() _time==12
F&F (OT=834) OT_CALC==500  micros() _time==13
F&F (OT=835) OT_CALC==500  micros() _time==11
F&F (OT=836) OT_CALC==500  micros() _time==13
F&F (OT=837) OT_CALC==500  micros() _time==13
F&F (OT=838) OT_CALC==500  micros() _time==11
F&F (OT=839) OT_CALC==500  micros() _time==11
F&F (OT=840) OT_CALC==500  micros() _time==13
F&F (OT=841) OT_CALC==500  micros() _time==14
F&F (OT=842) OT_CALC==500  micros() _time==11
F&F (OT=843) OT_CALC==500  micros() _time==13
F&F (OT=844) OT_CALC==500  micros() _time==12
F&F (OT=845) OT_CALC==500  micros() _time==13
F&F (OT=846) OT_CALC==500  micros() _time==11
F&F (OT=847) OT_CALC==500  micros() _time==13
F&F (OT=848) OT_CALC==500  micros() _time==13

err had to edit the OverTime++ _time to be set before it
Code:
    Serial.print("F&F (OT=");
    Serial.print( OverTime );
    Serial.print(")");

    Serial.print(" OT_CALC==");
    Serial.print(OT_CALC);
    Serial.print("  micros() _time==");
    [COLOR="#FF0000"]_time = micros() - _time;[/COLOR]
    if ( _time > OT_CALC ) OverTime++;

    __countB++;
    if ( __countB % 25 )
      teensy_gpio.transfer16((uint16_t *)MST_PrintVals, sizeof(MST_PrintVals) / 2, 60, 1); // DEBUGHACK output
    else
      teensy_gpio.transfer16((uint16_t *)MST_PrintVals, sizeof(MST_PrintVals) / 2, 55, 1);
    Serial.println(_time);

Output good now:
Code:
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==12
^LTF&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
^LTF&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
^LTF&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==12
F&F (OT=0) OT_CALC==500  micros() _time==11
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==13
F&F (OT=0) OT_CALC==500  micros() _time==11

Code:
6.00, #, #, #, #, #, #, #, #, #,223454,5 [476 ,0
44926.00, #, #, #, #, #, #, #, #, #,223455,5 [476 ,0
44936.00, #, #, #, #, #, #, #, #, #,223456,5 [476 ,0
44946.00, #, #, #, #, #, #, #, #, #,223457,5 [476 ,0
44956.00, #, #, #, #, #, #, #, #, #,223458,5 [476 ,0
44966.00, #, #, #, #, #, #, #, #, #,223459,5 [476 ,0
44976.00, #, #, #, #, #, #, #, #, #,223460,5 [476 ,0
44986.00, #, #, #, #, #, #, #, #, #,223461,5 [476 ,0
44996.00, #, #, #, #, #, #, #, #, #,223462,5 [476 ,0
45006.00, #, #, #, #, #, #, #, #, #,223463,5 [476 ,0
45016.00, #, #, #, #, #, #, #, #, #,223464,5 [476 ,0
45026.00, #, #, #, #, #, #, #, #, #,223465,5 [476 ,0
45036.00, #, #, #, #, #, #, #, #, #,223466,5 [476 ,0
45046.00, #, #, #, #, #, #, #, #, #,223467,5 [476 ,0
45056.00, #, #, #, #, #, #, #, #, #,223468,5 [476 ,0
45066.00, #, #, #, #, #, #, #, #, #,223469,5 [476 ,0
45076.00, #, #, #, #, #, #, #, #, #,223470,5 [476 ,0
45086.00, #, #, #, #, #, #, #, #, #,223471,5 [476 ,0
45096.00  45097.00  45098.00  45099.00  45100.00  45101.00  45102.00  45103.00  45104.00  45105.00  
45106.00, #, #, #, #, #, #, #, #, #,223472,5 [476 ,0
45116.00, #, #, #, #, #, #, #, #, #,223473,5 [476 ,0
45126.00, #, #, #, #, #, #, #, #, #,223474,5 [476 ,0
45136.00, #, #, #, #, #, #, #, #, #,223475,5 [476 ,0
45146.00, #, #, #, #, #, #, #, #, #,223476,5 [476 ,0
45156.00, #, #, #, #, #, #, #, #, #,223477,5 [476 ,0
45166.00, #, #, #, #, #, #, #, #, #,223478,5 [476 ,0
45176.00, #, #, #, #, #, #, #, #, #,223479,5 [476 ,0
45186.00, #, #, #, #, #, #, #, #, #,223480,5 [476 ,0
45196.00, #, #, #, #, #, #, #, #, #,223481,5 [476 ,0
45206.00, #, #, #, #, #, #, #, #, #,223482,5 [476 ,0
45216.00, #, #, #, #, #, #, #, #, #,223483,5 [476 ,0
45226.00, #, #, #, #, #, #, #, #, #,223484,5 [476 ,0
45236.00, #, #, #, #, #, #, #, #, #,223485,5 [476 ,0
45246.00, #, #, #, #, #, #, #, #, #,223486,5 [476 ,0
45256.00, #, #, #, #, #, #, #, #, #,223487,5 [476 ,0
45266.00, #, #, #, #, #, #, #, #, #,223488,5 [476 ,0
45276.00, #, #, #, #, #, #, #, #, #,223489,5 [476 ,0
45286.00, #, #, #, #, #, #, #, #, #,223490,5 [476 ,0
45296.00, #, #, #, #, #, #, #, #, #,223491,5 [476 ,0
45306.00, #, #, #, #, #, #, #, #, #,223492,5 [476 ,0
45316.00, #, #, #, #, #, #, #, #, #,223493,5 [476 ,0
45326.00, #, #, #, #, #, #, #, #, #,223494,5 [476 ,0
45336.00, #, #, #, #, #, #, #, #, #,223495,5 [476 ,0
45346.00  45347.00  45348.00  45349.00  45350.00  45351.00  45352.00  45353.00  45354.00  45355.00  
45356.00, #, #, #, #, #, #, #, #, #,223496,5 [476 ,0
45366.00, #, #, #, #, #, #, #, #, #,223497,5 [476 ,0
45376.00, #, #, #, #, #, #, #, #, #,223498,5 [476 ,0
45386.00, #, #, #, #, #, #, #, #, #,223499,5 [476 ,0
45396.00, #, #, #, #, #, #, #, #, #,223500,5 [476 ,0
45406.00, #, #, #, #, #, #, #, #, #,223501,5 [476 ,0
45416.00, #, #, #, #, #, #, #, #, #,223502,5 [476 ,0
45426.00, #, #, #, #, #, #, #, #, #,223503,5 [476 ,0
45436.00, #, #, #, #, #, #, #, #, #,223504,5 [476 ,0
45446.00, #, #, #, #, #, #, #, #, #,223505,5 [476 ,0
45456.00, #, #, #, #, #, #, #, #, #,223506,5 [476 ,0
45466.00, #, #, #, #, #, #, #, #, #,223507,5 [476 ,0
45476.00, #, #, #, #, #, #, #, #, #,223508,5 [476 ,0
45486.00, #, #, #, #, #, #, #, #, #,223509,5 [476 ,0
45496.00, #, #, #, #, #, #, #, #, #,223510,5 [476 ,0
45506.00, #, #, #, #, #, #, #, #, #,223511,5 [476 ,0
45516.00, #, #, #, #, #, #, #, #, #,223512,5 [476 ,0
45526.00, #, #, #, #, #, #, #, #, #,223513,5 [476 ,0
45536.00, #, #, #, #, #, #, #, #, #,223514,5 [476 ,0
45546.00, #, #, #, #, #, #, #, #, #,223515,5 [476 ,0
45556.00, #, #, #, #, #, #, #, #, #,223516,5 [476 ,0
45566.00, #, #, #, #, #, #, #, #, #,223517,5 [476 ,0
45576.00, #, #, #, #, #, #, #, #, #,223518,5 [476 ,0
45586.00, #, #, #, #, #, #, #, #, #,223519,5 [476 ,0
45596.00  45597.00  45598.00  45599.00  45600.00  45601.00  45602.00  45603.00  45604.00  45605.00  
45606.00, #, #, #, #, #, #, #, #, #,223520,5 [476 ,0
45616.00, #, #, #, #, #, #, #, #, #,223521,5 [476 ,0
45626.00, #, #, #, #, #, #, #, #, #,223522,5 [476 ,0
45636.00, #, #, #, #, #, #, #, #, #,223523,5 [476 ,0
45646.00, #, #, #, #, #, #, #, #, #,223524,5 [476 ,0
45656.00, #, #, #, #, #, #, #, #, #,223525,5 [476 ,0
45666.00, #, #, #, #, #, #, #, #, #,223526,5 [476 ,0
45676.00, #, #, #, #, #, #, #, #, #,223527,5 [476 ,0
45686.00, #, #, #, #, #, #, #, #, #,223528,5 [476 ,0
45696.00, #, #, #, #, #, #, #, #, #,223529,5 [476 ,0
45706.00, #, #, #, #, #, #, #, #, #,223530,5 [476 ,0
45716.00, #, #, #, #, #, #, #, #, #,223531,5 [476 ,0
45726.00, #, #, #, #, #, #, #, #, #,223532,5 [476 ,0
45736.00, #, #, #, #, #, #, #, #, #,223533,5 [476 ,0
45746.00, #, #, #, #, #, #, #, #, #,223534,5 [476 ,0
45756.00, #, #, #, #, #, #, #, #, #,223535,5 [476 ,0
45766.00, #, #, #, #, #, #, #, #, #,223536,5 [476 ,0
45776.00, #, #, #, #, #, #, #, #, #,223537,5 [476 ,0
45786.00, #, #, #, #, #, #, #, #, #,223538,5 [476 ,0
45796.00, #, #, #, #, #, #, #, #, #,223539,5 [476 ,0
45806.00, #, #, #, #, #, #, #, #, #,223540,5 [476 ,0
45816.00, #, #, #, #, #, #, #, #, #,223541,5 [476 ,0
45826.00, #, #, #, #, #, #, #, #, #,223542,5 [476 ,0
45836.00, #, #, #, #, #, #, #, #, #,223543,5 [476 ,0
45846.00  45847.00  45848.00  45849.00  45850.00  45851.00  45852.00  45853.00  45854.00  45855.00  
45856.00, #, #, #, #, #, #, #, #, #,223544,5 [476 ,0
45866.00, #, #, #, #, #, #, #, #, #,223545,5 [476 ,0

The 5 is from reprogramming the master couple times

At 6MHz, I don't see the slave counting errors or the master OT's rising either.
But you must enable LCmode(10,10), if values are less than this it'll crash
 
Last edited:
I'm back. Ok couple questions:
1. LCMode requires 10,10: both gpio and gpio2? assuming both if over 6MHz
2. gpio2 stays at 4Mhz?

Thanks for fixing the code, works better now. So wrapped up in testing forgot about the large values.
 
Just as a FYI, at 10MHz/4MHz for spi with no OTs. Going to 12 now to see what happens. I am at 100ms toggle and 10ms F&Fs.

OK hangs at 12MHz. Oh well had to try. Now to increase gpio speed

EDIT: This is what I am using for control:
Code:
  if(SPI_SPEED > 4000000){
    teensy_gpio.LCmode(10,10);
    teensy_gpio2.LCmode(10,10);  
  } else {
    teensy_gpio.LCmode(0,5);
    teensy_gpio2.LCmode(0,5);
  }


UPDATE: At 10/6 works, no OTs or errors but periodic pauses. More testing.....

UPDATE1: At 8/6 works but periodic pauses...... Looks like 6/6 is the max. Will let you know. Nope - getting periodic pause at 6/6

UPDATE2: 8/4 works nicely no pauses..... 10/4 I worked nicely as well. Oh, I forgot I am using a T3.5/LC for testing so a T3.6/LC might work better.
...
UPDATE3: 10/4 with 2ms (was 10ms) F&Fs works but not smooth... changed LCmode but no good......... 5ms works with 10/10 but does act funny with 10/10 kindof ... at 15/15 for LCmode works better.
 
Last edited:
Don't what else to test.....

EDIT: At 6/6 with lcmode(10,10) and 5ms f&fs still get those periodic pauses. At 10ms F&Fs still get the pauses intermittently. They seem to occur at random times as well. No particular pattern.
 
Last edited:
pauses seem to dissipate at ~20 using your 5ms F&F's (testing now), I think by the way it's acting, it's as if the LC is trying to do background processing (im using Smallest compile optimization)

EDIT, no difference with fastest
 
Yup, must be processing time! change the F&F's to 10ms and its smoooooooth, LC is slow, needs time to process those dwords :)
 
Yep - oh well but nice work. Having fun with testing but think I am done now for a while unless you throw something else at me. :)
 
Unless you want me to fiddle with it sommore for 8mhz, I think we can live with 6MHz for the LC. We'll just give the slave tests some runs before I'll start the ISR conversion :)

Before I mess up, I just converted the UART section and tested printing "Hello World" from the master at 6MHz
Code:
[ATTACH]13826._xfImport[/ATTACH]

master code:
Code:
 teensy_gpio3.println("Hello World!");

slave output:
Code:
7414.00, #, #, #, #, #, #, #, #, #,17486,2 [98 ,0
57424.00, #, #, #, #, #, #, #, #, #,17487,2 [98 ,0
57434.00, #, #, #, #, #, #, #, #, #,17488,2 [98 ,0
57444.00, #, #, #, #, #, #, #, #, #,17489,2 [98 ,0
57454.00  57455.00  57456.00  57457.00  57458.00  57459.00  57460.00  57461.00  57462.00  57463.00  
[COLOR="#0000FF"][B]Hello World![/B][/COLOR]
57464.00, #, #, #, #, #, #, #, #, #,17490,2 [98 ,0
57474.00, #, #, #, #, #, #, #, #, #,17491,2 [98 ,0
57484.00, #, #, #, #, #, #, #, #, #,17492,2 [98 ,0
57494.00, #, #, #, #, #, #, #, #, #,17493,2 [98 ,0
57504.00, #, #, #, #, #, #, #, #, #,17494,2 [98 ,0

Update #2, EEPROM & WIRE conversion
Code:
[ATTACH]13827._xfImport[/ATTACH]

and finally Update #3, all ISR converted!
Code:
[ATTACH]13828._xfImport[/ATTACH]

Code:
	Teensy LC Detected.

		Circular buffer capacity: 8
		Circular buffer length:   50

	Using SPI0 as slave, pin configuration:

		  Slave:		   Master:

		  CS    2 -------------->  CS
		  MOSI 11 -------------->  MISO
		  MISO 12 -------------->  MOSI
		  SCK  14 -------------->  SCK

Bad LASTVAL TEST INCREMENT <<<<<<<<<<<<<<<<<<<< DIFF OF> 34837.00
65174.00,65175.00,65176.00,65177.00,65178.00,65179.00,65180.00,65181.00,65182.00,65183.00,1,1 [0 ,0
65184.00, #, #, #, #, #, #, #, #, #,2,1 [0 ,0
65194.00, #, #, #, #, #, #, #, #, #,3,1 [0 ,0
65204.00  65205.00  65206.00  65207.00  65208.00  65209.00  65210.00  65211.00  65212.00  65213.00  
65214.00, #, #, #, #, #, #, #, #, #,4,1 [0 ,0
65224.00, #, #, #, #, #, #, #, #, #,5,1 [0 ,0
65234.00, #, #, #, #, #, #, #, #, #,6,1 [0 ,0
65244.00, #, #, #, #, #, #, #, #, #,7,1 [0 ,0
65254.00, #, #, #, #, #, #, #, #, #,8,1 [0 ,0
65264.00, #, #, #, #, #, #, #, #, #,9,1 [0 ,0
65274.00, #, #, #, #, #, #, #, #, #,10,1 [0 ,0
65284.00, #, #, #, #, #, #, #, #, #,11,1 [0 ,0
65294.00, #, #, #, #, #, #, #, #, #,12,1 [0 ,0
65304.00, #, #, #, #, #, #, #, #, #,13,1 [0 ,0
65314.00, #, #, #, #, #, #, #, #, #,14,1 [0 ,0
65324.00, #, #, #, #, #, #, #, #, #,15,1 [0 ,0
65334.00, #, #, #, #, #, #, #, #, #,16,1 [0 ,0

:)


or this? :)
Code:
	Teensy LC Detected.

		Circular buffer capacity: 8
		Circular buffer length:   50

	Available remote controlled resources:
	USBSerial, gpio, Wire, analog, Eeprom, SPI, Serial1, Serial2, Serial3, Serial4, Serial5, Serial6

	Using SPI0 as slave, pin configuration:

		  Slave:		   Master:

		  CS    2 -------------->  CS
		  MOSI 11 -------------->  MISO
		  MISO 12 -------------->  MOSI
		  SCK  14 -------------->  SCK
 
Last edited:
Hi Tony
Think I like the second version better :) Can't have too much info :)

EDIT
Unless you want me to fiddle with it sommore for 8mhz, I think we can live with 6MHz for the LC.
6 MHz is good for me.

UPDATE:
Loaded slave sketch - updated master to do the println. Running at 10MHz SPI and 4 MHz GPIO2 and GPIO3. All running good so far. It hung once and trying it again to make sure it wasn't me - I have a loose usb cable - have to replace it - will let you know.

UPDATE2: OOPS - was running the 10 at 5ms F&F same for 6 that I just tested. Both hung eventually think it was on the slave side. Just fixed and rerunning the 6/4 case with 10ms F&Fs......

so far so good going to let it run a while....
 
Last edited:
im running all 6mhz, 8ms f&fs 10,10LC mode 100ms led toggle, and on slave i have 500ms transfer16’s :)

Oh yeah here is the update with the resource listing

Code:
[ATTACH]13831._xfImport[/ATTACH]
 
Last edited:
I am running now at 6/4 MHz, 10ms f&fs, 10,10lcmode, 100ms toggle and println(hello worlds). Slave I have the same - 500ms transfer 16s. :) I do have the Hello world in the same loop as the toggle so we will see. Had another hang up after about 15minutes but rearranged the println to after the delay(1) in the timer to see if that may have caused the problem. Will keep you posted.

EDIT: 5ms is definitely a little too short for the LC.
 
I do have the Hello world in the same loop as the toggle so we will see.

forgot to say that I have it where the Led is toggling as well :)

yup i experienced the long run then freeze, ill look into it, that will be a looooong check to do, but, in the meantime, im almost done having the stripped down master and the slave working in same folder
both sides compile now master & slave, provided the proper .h is included in the sketch of course
 
Last edited:
Back
Top