Cpnnecting SPI LCD screen to T4

donperryjm

Well-known member
Hello, I'm trying to find the right pins on the T4 for each of these SPI connections on this LCD

61XKJGexQxL._AC_SL1114_.jpgspi.jpg
Capture.jpg

DIN=MOSI/11?
CLK=13?
CS=10?
DC=?


edit: found this in the libary for the LCD

#define DEV_CS_PIN 10
#define DEV_DC_PIN 7
#define DEV_RST_PIN 8
#define DEV_BL_PIN 9
 
Last edited:
I should think that you can use the same connection detail as for the Arduino UNO shown here complete with code.
 
Might help if you showed a picture of your setup,

plus simple sketch showing your issue, which might include details like what library you are using and the like.
 
https://www.waveshare.com/w/upload/f/fc/LCD_Module_code.zip

I'm running the arduino sample inside this zip. Untouched.

And I have it wired up:
WhatsApp Image 2022-06-07 at 9.31.14 AM.jpg

VCC and GDN as expected
DIN going to pin 11
CLK going to 13
CS going to 10
DC going to 7
RST going to 8
BL going to 9

inside of their library you will see:
Code:
/**
 * GPIO config
**/
#define DEV_CS_PIN  10
#define DEV_DC_PIN  7
#define DEV_RST_PIN 8
#define DEV_BL_PIN  9
 
Sorry from your picture I can not tell on teensy where the power and gnd are hooked up.

Backlight they do PinMode(...) and then they do analogWrite to it. Not sure if that is working.

Or if it is needing 5v or ???
 
OPERATING VOLTAGE:3.3V / 5V
DISPLAY PANEL: IPS. PIXEL SIZE: 0.135 × 0.135mm; DRIVER: GC9A01

power n GND are hooked up correctly. The USB port is to the left of the photo. White>gnd and purple>VCC.

Gonna look for pinmode and such.
Edit:
removed the pinmode line, no change.
 
Maybe if you change SPI_MODE3 to SPI_MODE0 in the DEV_Config.ccp file

To fine-tune the speed of the SPI port, consider using the SPI.beginTransaction statement, after SPI.begin()

For example:
SPI.beginTransaction(SPISettings(36000000, MSBFIRST, SPI_MODE0));
 
Last edited:
In their sketch what happens if you:
LCD_SetBacklight(1000);

change the 1000 to 254?

As PWM defaults to 8 bits mode...

OR at start of setup add: analogWriteResolution(10);
Which would make 1000 valid...

Or as a quick test, if you simply replace the Setbacklight with:
pinMode(DEV_BL_PIN, OUTPUT);
digitalWrite(DEV_BL_PIN , HIGH);
 
Backlight is responding to above code, if i change the value lower it gets dimmer.

Code:
	analogWriteResolution(10);
	Config_Init();
	LCD_Init();
	LCD_SetBacklight(1000);

how it is now
 
Just tried an arduino nano and it worked.
So something up with what i'm doing with T4.

I took a new T4 out the box and same non result.
 
Trying a T3.2 and it won't link.


Code:
 Error linking for board Teensy 3.2 / 3.1
libc.a(lib_a-writer.o)*: In function _write_r
writer.c*: (.text._write_r+0x12): undefined reference to _write
 
collect2.exe*: error: ld returned 1 exit status
Build failed for project 'LCD_round'
 
You might try something like change:
Code:
 void Config_Init()
 {

  GPIO_Init();
  
  //Serial
  Serial.begin(115200);
  
  //spi
  SPI.setDataMode(SPI_MODE3);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV2);
  SPI.begin();
  }

Code:
 void Config_Init()
 {

  GPIO_Init();
  
  //Serial
  Serial.begin(115200);
  
  //spi
  //SPI.setDataMode(SPI_MODE3);
  //SPI.setBitOrder(MSBFIRST);
  //SPI.setClockDivider(SPI_CLOCK_DIV2);
  
  SPI.begin();
  SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE3));
  }
And see if anything shows up.
 
You might try something like change:
Code:
 void Config_Init()
 {

  GPIO_Init();
  
  //Serial
  Serial.begin(115200);
  
  //spi
  SPI.setDataMode(SPI_MODE3);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV2);
  SPI.begin();
  }

Code:
 void Config_Init()
 {

  GPIO_Init();
  
  //Serial
  Serial.begin(115200);
  
  //spi
  //SPI.setDataMode(SPI_MODE3);
  //SPI.setBitOrder(MSBFIRST);
  //SPI.setClockDivider(SPI_CLOCK_DIV2);
  
  SPI.begin();
  SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE3));
  }
And see if anything shows up.

Tried nothing changed

I found this repository with an adaptation of the ILI9341 library to handle the GC9A01 driver. Try using it on your screen:

https://github.com/PaintYourDragon/Adafruit_GC9A01A

OK I'll explore this a little later, as i got it working with the arduino nano. So the library is good. But something is up with Teensy library I think.
 
Back
Top