Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timing issue using Teensy 4.0 #36

Open
ghost opened this issue Oct 4, 2020 · 0 comments
Open

Timing issue using Teensy 4.0 #36

ghost opened this issue Oct 4, 2020 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 4, 2020

I have found that there appears to be a timing issue when using the L6470 library on a Teensy 4.0. The Teensy sends the next byte before the previous was processed by the L6470.

I have traced the problem to the SPIXfer() function, and have made it work by inserting delays at strategic locations

byte AutoDriver::SPIXfer(byte data)
{
byte dataPacket[_numBoards];
int i;
for (i=0; i < _numBoards; i++)
{
dataPacket[i] = 0;
}
dataPacket[_position] = data;
digitalWrite(_CSPin, LOW);
delayMicroseconds(1);
_SPI->beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
_SPI->transfer(dataPacket, _numBoards);
delayMicroseconds(1);
_SPI->endTransaction();
digitalWrite(_CSPin, HIGH);
delayMicroseconds(5);
return dataPacket[_position];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants