Teensy 3.6
SdFat 1.0.7 - using SdFatSdioEX
Serial1-Serial6
Examples->SdFat->TeensySdioDemo
I hit a strange issue where:
* Only if using Serial1 - Serial6, not the built in usb Serial
* Only if using SdFatSdioEX, not SdFatSdio
After doing sd.begin() or file.open(), I can no longer send more than 64 bytes to SerialN.
On the 65th cumulative byte of any form of Serial1.print() println() write() etc, in any combintion, the Teensy locks up.
I found that if I avoid writing 64 bytes until a file.write(), then after the file.write() the uart is fixed and I can once again write as much as I want to it.
I found that file.sync() also clears the problem.
Both file.write() and file.sync() require a file to be opened though, but the problem also happens after sd.begin() and no file has been opened yet.
I found that sd.cacheClear() also clears the problem, and doesn't need any file opened.
So in the end the best work-around I found is to either not use SdFatSdioEX (use SdFatSdio instead),
or issue a sd.cacheClear() immediately after any sd.begin() or file.open().
Except there is still something missing, because I hit this problem in code that started out as a copy of TeensySdioDemo.
To show the problem cleanly without a lot of other junk, I made a minimal new sketch from scratch, that adhered to all the rules I described, and it does NOT exhibit the problem!
But if I take a fresh copy of TeensySdioDemo and just do the minimum changes to that (global replace Serial to Serial1, and add some Serial1.println() so it exceeds 64 bytes in the problem spots, and that's IT, no other changes), the problem exists and is easily shown, and it's easilt shown that adding sd.cacheClear() fixes it.
A little more detail here:
https://github.com/greiman/SdFat/issues/112
Attached are two sketches
The clean/minimal one which SHOULD be failing in it's current state, according to all I just said, but is working fine.
(two sd.cacheClear() are commented out, and so the next stest() after sd.begin() should lock up the Teensy, but it isn't)
A copy of TeensySdioDemo with the minimum changes to show the problem and the work-around.
If you comment-out either sdEx.cachClear() in this one, it locks up in the next stest().
To see just the changed parts, search for "BKW" in this one. The only changes are:
* global replace Serial to Serial1 - that should be perfecty "legal", it doesn't functionally change anything as long as you actually have something hooked to the serial port. (I am using a Schmartboard cmos-rs232 shfter, powered from one of the teensys 3.3v pins (not Vin or VUSB). The serial connection is working perfectly outside of this specific conflict.
* Insert some more Serial1.println() in various places to show that it's harmless some places and causes a lockup in other places.
Any ideas what the heck is going on?
SdFat 1.0.7 - using SdFatSdioEX
Serial1-Serial6
Examples->SdFat->TeensySdioDemo
I hit a strange issue where:
* Only if using Serial1 - Serial6, not the built in usb Serial
* Only if using SdFatSdioEX, not SdFatSdio
After doing sd.begin() or file.open(), I can no longer send more than 64 bytes to SerialN.
On the 65th cumulative byte of any form of Serial1.print() println() write() etc, in any combintion, the Teensy locks up.
I found that if I avoid writing 64 bytes until a file.write(), then after the file.write() the uart is fixed and I can once again write as much as I want to it.
I found that file.sync() also clears the problem.
Both file.write() and file.sync() require a file to be opened though, but the problem also happens after sd.begin() and no file has been opened yet.
I found that sd.cacheClear() also clears the problem, and doesn't need any file opened.
So in the end the best work-around I found is to either not use SdFatSdioEX (use SdFatSdio instead),
or issue a sd.cacheClear() immediately after any sd.begin() or file.open().
Except there is still something missing, because I hit this problem in code that started out as a copy of TeensySdioDemo.
To show the problem cleanly without a lot of other junk, I made a minimal new sketch from scratch, that adhered to all the rules I described, and it does NOT exhibit the problem!
But if I take a fresh copy of TeensySdioDemo and just do the minimum changes to that (global replace Serial to Serial1, and add some Serial1.println() so it exceeds 64 bytes in the problem spots, and that's IT, no other changes), the problem exists and is easily shown, and it's easilt shown that adding sd.cacheClear() fixes it.
A little more detail here:
https://github.com/greiman/SdFat/issues/112
Attached are two sketches
The clean/minimal one which SHOULD be failing in it's current state, according to all I just said, but is working fine.
(two sd.cacheClear() are commented out, and so the next stest() after sd.begin() should lock up the Teensy, but it isn't)
A copy of TeensySdioDemo with the minimum changes to show the problem and the work-around.
If you comment-out either sdEx.cachClear() in this one, it locks up in the next stest().
To see just the changed parts, search for "BKW" in this one. The only changes are:
* global replace Serial to Serial1 - that should be perfecty "legal", it doesn't functionally change anything as long as you actually have something hooked to the serial port. (I am using a Schmartboard cmos-rs232 shfter, powered from one of the teensys 3.3v pins (not Vin or VUSB). The serial connection is working perfectly outside of this specific conflict.
* Insert some more Serial1.println() in various places to show that it's harmless some places and causes a lockup in other places.
Any ideas what the heck is going on?