Hi folks,
I'm having an apparent "garbled comms" issue with the Teensy 3.6 and two different SPI/I2C/serial LCD's marketed by SparkFun and sold on Amazon.
The model # is 14073, and the SPI library is from TeensyDuino 1.44. (I assume - I haven't done anything special The Arduino IDE version is 1.8.7 .
Some characters displayed on the LCD are what I would expect to see, but most are garbage - blanks, other alpha etc. I have not as yet put a logic analyzer on, primarily because I'm old and don't have a 3.3V analyzer. (yet) The LCD is powered by a separate 5V rail with its own 3.3V sub-regulator, which is bypassed and shows no bad habits on a 100 mHZ scope. The power grounds are common, of course.
Here's the code I'm using. I scraped the SPI commands from a demo. I've used Teensy boards primarily for audio projects up until now, so this is my first SPI project with it. I am operating under the
*assumption* that the code below will compile/link the Teensy library, although that may or may not be true - not a TeensyDuino expert by any means.
Ideas solicited, thanks!
Sketch code:
// include the SPI library:
#include <SPI.h>
// set pin 10 as the slave select for the digital pot:
const int csPin = 10;
void setup()
{
delay(1000); // Give the display MCU time to boot
pinMode (csPin, OUTPUT);
digitalWrite (csPin, HIGH);
// initialize SPI:
SPI.begin();
// Write R, G & B backlight values for max brightness (initial test)
writeLCD(0x9D);
delay(100);
writeLCD(0xBB);
delay(100);
writeLCD(0xD9);
delay(100);
}
void loop()
{
writeLCD('A');
delay(100);
writeLCD('B');
delay(100);
writeLCD('C');
delay(100);
writeLCD('D');
delay(100);
}
void writeLCD(int value)
{
// gain control of the SPI port
// and configure settings
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
// take the SS pin low to select the chip:
digitalWrite(csPin,LOW);
// send in the value via SPI:
SPI.transfer(value);
// take the SS pin high to de-select the chip:
digitalWrite(csPin,HIGH);
// release control of the SPI port
SPI.endTransaction();
}
I'm having an apparent "garbled comms" issue with the Teensy 3.6 and two different SPI/I2C/serial LCD's marketed by SparkFun and sold on Amazon.
The model # is 14073, and the SPI library is from TeensyDuino 1.44. (I assume - I haven't done anything special The Arduino IDE version is 1.8.7 .
Some characters displayed on the LCD are what I would expect to see, but most are garbage - blanks, other alpha etc. I have not as yet put a logic analyzer on, primarily because I'm old and don't have a 3.3V analyzer. (yet) The LCD is powered by a separate 5V rail with its own 3.3V sub-regulator, which is bypassed and shows no bad habits on a 100 mHZ scope. The power grounds are common, of course.
Here's the code I'm using. I scraped the SPI commands from a demo. I've used Teensy boards primarily for audio projects up until now, so this is my first SPI project with it. I am operating under the
*assumption* that the code below will compile/link the Teensy library, although that may or may not be true - not a TeensyDuino expert by any means.
Ideas solicited, thanks!
Sketch code:
// include the SPI library:
#include <SPI.h>
// set pin 10 as the slave select for the digital pot:
const int csPin = 10;
void setup()
{
delay(1000); // Give the display MCU time to boot
pinMode (csPin, OUTPUT);
digitalWrite (csPin, HIGH);
// initialize SPI:
SPI.begin();
// Write R, G & B backlight values for max brightness (initial test)
writeLCD(0x9D);
delay(100);
writeLCD(0xBB);
delay(100);
writeLCD(0xD9);
delay(100);
}
void loop()
{
writeLCD('A');
delay(100);
writeLCD('B');
delay(100);
writeLCD('C');
delay(100);
writeLCD('D');
delay(100);
}
void writeLCD(int value)
{
// gain control of the SPI port
// and configure settings
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
// take the SS pin low to select the chip:
digitalWrite(csPin,LOW);
// send in the value via SPI:
SPI.transfer(value);
// take the SS pin high to de-select the chip:
digitalWrite(csPin,HIGH);
// release control of the SPI port
SPI.endTransaction();
}