
Originally Posted by
hubbe
So I tried the git revisions:
This is the last one that works for me: b2dd72f634ec0fff3d8c00d222a28b13e0ead8a9
The next check-in is "Single SPIClass for Teensy 3.x".
I tried commenting out some parts of my code (like reading the motion chip, and the WS2811 support) but that didn't seem to make any difference.
However, here is the weird part: I tried this on a prop shield, but didn't have a problem. So I tried on a different TeensySaber V2, and that also worked!
So, apparently, the problem only shows up on my test bed, and only with the newer SPI code....
So; that makes me think that maybe the timing is tighter, the speed is faster or the drive current is lower. (My test bed has longer traces than the other two things I tested.)
Next I'm going to dig out my old oscilloscope and see if I can tell what the difference is.
The difference is the drive strength.
The difference is in SPI.begin(), the old code says:
Code:
SPCR.enable_pins(); // pins managed by SPCRemulation in avr_emulation.h
The new code says:
Code:
reg = portConfigRegister(hardware().mosi_pin[mosi_pin_index]);
*reg = PORT_PCR_MUX(hardware().mosi_mux[mosi_pin_index]);
reg = portConfigRegister(hardware().miso_pin[miso_pin_index]);
*reg= PORT_PCR_MUX(hardware().miso_mux[miso_pin_index]);
reg = portConfigRegister(hardware().sck_pin[sck_pin_index]);
*reg = PORT_PCR_MUX(hardware().sck_mux[sck_pin_index]);
If I look in SPCR.enable_pin, it also sets PORT_PCR_DSE on the relevant pins, while it seems that the new code doesn't.
I tried using the new code, but calling SPCR.enable_pins() instead of doing the portConfigRegister stuff, and then everything works again.