Greetings!
I've been diving into SPI recently and I wonder if I may have found a bug with the SPI library as implemented for the T4? In SPI mode 0 the data are sampled on the rising edge of the clock. So, data transitions coincident with the clock's rising edge may or may not work depending on the exact details of the edges, and that shouldn't be allowed.
I noticed that SPI mode 0 writes looked odd on the T4, so I compiled and ran the code below on both the T4 and T3.6 (Teensyduino 1.49). The 'scope traces show that the first rising clock edge is coincident with a data transition for the T4, but the T3.6 looks good.
In both 'scope images chip select is pink, clock is yellow, and data is blue. Note that the data transitions coincident with the first clock edge on the first image (T4). Is this a bug, or am I missing something?
cheers,
Doug
I've been diving into SPI recently and I wonder if I may have found a bug with the SPI library as implemented for the T4? In SPI mode 0 the data are sampled on the rising edge of the clock. So, data transitions coincident with the clock's rising edge may or may not work depending on the exact details of the edges, and that shouldn't be allowed.
I noticed that SPI mode 0 writes looked odd on the T4, so I compiled and ran the code below on both the T4 and T3.6 (Teensyduino 1.49). The 'scope traces show that the first rising clock edge is coincident with a data transition for the T4, but the T3.6 looks good.
In both 'scope images chip select is pink, clock is yellow, and data is blue. Note that the data transitions coincident with the first clock edge on the first image (T4). Is this a bug, or am I missing something?
cheers,
Doug
Code:
#include "SPI.h"
uint8_t payload=0;
void setup()
{
Serial.begin(115200);
delay(5000);
pinMode(10, OUTPUT);
SPI.begin();
}
void loop()
{
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
digitalWriteFast(10, LOW);
Serial.println(SPI.transfer(payload));
Serial.println(payload);
payload++;
digitalWriteFast(10, HIGH);
SPI.endTransaction();
delay(2000);
}