EDIT: It seems these issues are something to do with the hardware I am using. For some reason when plugged in the teensy only sends half the packets it needs to. Without changing the program and removing the hardware it send the full number of packets. This is true for MODE0 or MODE2. What hardware issue can cause this behaviour?
I am having confusing issues with the T4.1 when using SPI. I am not seeing all the packets being transmitted in certain cases.
3 transactions in a loop repeating once, total of 6 bytes, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF. What was actually sent was 0xFF, 0xFF, 0x00.
The code as above with the delay uncommented leads to:
4 transactions, 0xFF, 0xFF, 0xFF, 0xFF and two delays (should be 6).
Done some more testing now. Thought I would try a non-blocking call (which I want in the end). Copied some code from the forums.
I set the array to count in binary, on my scope I can see the first 8 packets no problem, and correctly counting up. So I am even more confused now.
I am having confusing issues with the T4.1 when using SPI. I am not seeing all the packets being transmitted in certain cases.
3 transactions in a loop repeating once, total of 6 bytes, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF. What was actually sent was 0xFF, 0xFF, 0x00.
Code:
#include <SPI.h>
void setup() {
// put your setup code here, to run once:
pinMode(15, OUTPUT);
SPI.begin();
}
void loop() {
// put your main code here, to run repeatedly:
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE2));
byte zero = 0x01;
byte full = 0xFF;
byte out = 0;
digitalWriteFast(15, LOW);
for (int k = 0; k < 2; k++) {
out = SPI.transfer(full);
out++;
//delayMicroseconds(9);
out = SPI.transfer(zero);
out++;
//delayMicroseconds(9);
out = SPI.transfer(full);
out++;
//delayMicroseconds(9);
}
digitalWriteFast(15, HIGH);
SPI.endTransaction();
delay(1);
}
The code as above with the delay uncommented leads to:
4 transactions, 0xFF, 0xFF, 0xFF, 0xFF and two delays (should be 6).
Done some more testing now. Thought I would try a non-blocking call (which I want in the end). Copied some code from the forums.
Code:
#include <SPI.h>
EventResponder callbackHandler;
void setup() {
// put your setup code here, to run once:
pinMode(15, OUTPUT);
SPI.begin();
callbackHandler.attachImmediate(&callback);
}
#define arrLength 16
void loop() {
// put your main code here, to run repeatedly:
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE2));
byte zero[arrLength];
for(int k = 0; k < arrLength; k++){
zero[k] = k * 1;
}
digitalWriteFast(15, LOW);
SPI.transfer((void *)zero, nullptr, arrLength, callbackHandler);
digitalWriteFast(15, HIGH);
delay(1);
}
void callback(EventResponderRef eventResponder)
{
//end screen update
SPI.endTransaction();
}
I set the array to count in binary, on my scope I can see the first 8 packets no problem, and correctly counting up. So I am even more confused now.
Last edited: