Skip to content

Timing issue using Teensy 4.0 #36

@ghost

Description

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];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions