randomvibe
Well-known member
My Teensy3.6 with three SPI devices is having difficult intermittent problems.
On one hand I have a Teensy 3.6 project with two SPI devices that work solidly in a program for-loop: an IMU (LSM6DS3), and a display (ILI9341).
Separately, I hooked up a PIXY camera on another Teensy 3.6 with SPI. After some setup, the communication is solid and the Teensy echoes back tracking information in a for-loop.
When I merge all three SPI devices on MISO0/MOSI0/SCK0 with separate SS channels, the PIXY SPI readings are only spotty. Tracking information is intermittently missed. When I remove the ILI9341 display, the problem persists. To my surprise, when I reconnect the display and remove the IMU, the PIXY readings are solid.
Each device uses a different SS channel. See code below. I lowered the IMU speed from 10MHz to the PIXY speed of 1MHz, but no luck. What can go wrong with multiple SPI devices at different speeds sharing the same SPI ports?
On one hand I have a Teensy 3.6 project with two SPI devices that work solidly in a program for-loop: an IMU (LSM6DS3), and a display (ILI9341).
Separately, I hooked up a PIXY camera on another Teensy 3.6 with SPI. After some setup, the communication is solid and the Teensy echoes back tracking information in a for-loop.
When I merge all three SPI devices on MISO0/MOSI0/SCK0 with separate SS channels, the PIXY SPI readings are only spotty. Tracking information is intermittently missed. When I remove the ILI9341 display, the problem persists. To my surprise, when I reconnect the display and remove the IMU, the PIXY readings are solid.
Each device uses a different SS channel. See code below. I lowered the IMU speed from 10MHz to the PIXY speed of 1MHz, but no luck. What can go wrong with multiple SPI devices at different speeds sharing the same SPI ports?
Code:
// LSM6DS3 IMU
#define READ 0x80
#define WRITE 0x00
#define MOSIX 11
#define SCKX 13
#define MISOX 12
#define CSX 15 // SS channel
SPISettings IMUSPI(10000000, MSBFIRST, SPI_MODE0); // 10MHz
// ILI9341 DISPLAY
#define TFT_CS 10 // SS channel
#define TFT_DC 9
#define TFT_RST 255
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC, TFT_RST, MOSIX, SCKX, MISOX);
// PIXY Teensy 3.5/3.6 SPI Pins
#define PIXY_SPI_CS 20 // SS channel
SPISettings PIXYSPI(1000000, MSBFIRST, SPI_MODE0); // 1MHz
void spi_initialize()
{
pinMode(CSX, OUTPUT);
digitalWrite(CSX,HIGH);
pinMode( PIXY_SPI_CS, OUTPUT);
digitalWrite( PIXY_SPI_CS,HIGH);
SPI.setMOSI(MOSIX);
SPI.setMISO(MISOX);
SPI.setSCK(SCKX);
SPI.begin();
}