Blackaddr
Well-known member
I've got SPI0 working no problem on my project but I can't seem to get SPI1 to do anything. When I probe the SCK1 and MOSI1 pins I get nothing on the scope when attempting to use SPI1. Here's a basic sketch, perhaps you can spot what I'm missing.
For this test, the Teensy 3.6 is not connected to anything other than USB, it's freestanding on a static bench.
The sketch has two modes. I use IO_CHECK to toggle the associated output pins to ensure they are not damaged. When I #define IO_CHECK, the scope sees the square wave on all three output pins tested.
When I switch to #define SPI1_CHECK, I see the CS pin toggling but nothing on the SCK1 or MOSI1 pins. I've searched and found some sketches uses SPI1 and I can't spot what I'm missing.
Any ideas?
For this test, the Teensy 3.6 is not connected to anything other than USB, it's freestanding on a static bench.
The sketch has two modes. I use IO_CHECK to toggle the associated output pins to ensure they are not damaged. When I #define IO_CHECK, the scope sees the square wave on all three output pins tested.
When I switch to #define SPI1_CHECK, I see the CS pin toggling but nothing on the SCK1 or MOSI1 pins. I've searched and found some sketches uses SPI1 and I can't spot what I'm missing.
Any ideas?
Code:
#include <SPI.h>
//#define IO_CHECK
#define SPI1_CHECK
const int spiCsPin = 31;
const int spiSckPin = 20;
const int spiMosiPin = 21;
const int spiMisoPin = 5;
SPISettings spiMemSettings(1000000, MSBFIRST, SPI_MODE0);
void setup() {
pinMode(spiCsPin, OUTPUT); // SPI CS
// put your setup code here, to run once:
#ifdef IO_CHECK
pinMode(spiSckPin, OUTPUT); // SPI_SCK pin
pinMode(spiMosiPin, OUTPUT); // SPI_MOSI pin
#endif
#ifdef SPI1_CHECK
SPI1.begin();
SPI1.setMOSI(spiMosiPin);
SPI1.setMISO(spiMisoPin);
SPI1.setSCK(spiSckPin);
#endif
}
void loop() {
// put your main code here, to run repeatedly:
#ifdef SPI1_CHECK
SPI1.beginTransaction(spiMemSettings);
digitalWrite(spiCsPin, LOW);
SPI1.transfer(0);
SPI1.transfer(0);
SPI1.transfer(0);
SPI1.transfer(0xaa);
SPI1.endTransaction();
digitalWrite(spiCsPin, HIGH);
#endif
#ifdef IO_CHECK
digitalWrite(spiCsPin, HIGH);
digitalWrite(spiSckPin, HIGH);
digitalWrite(spiMosiPin, HIGH);
delay(1);
digitalWrite(spiCsPin, LOW);
digitalWrite(spiSckPin, LOW);
digitalWrite(spiMosiPin, LOW);
delay(1);
#endif
}