STM32F103C8 and 9325 unusual display

Post here all questions related to LibMaple core if you can't find a relevant section!
Post Reply
Chloe
Posts: 3
Joined: Sun Nov 12, 2023 1:50 pm

STM32F103C8 and 9325 unusual display

Post by Chloe »

Hi guys, I am trying to get this display to work and have hit a wall. I will break down what I have tried so far.

LCD Identification
Under the LCD it has CL9325-115 on the ribbon. It is part of original Jyetech DSO-138 kit I got some years ago from Banggood. Most of these originally seem to be with 9341. I tried to get its ID over serial with readID(); sometimes it reports strange numbers, for example 1690 hex, 4112 dec/1010 hex.

Getting LCD to display something other than white screen
For some reason I don't understand, only the TFT code from DLO-138 project partial works after changing the display to 0x9325. I tried compiling with earlier version of GFX library as per the instructions but it only gave white screen.

Image

Since the screen looks so close, I was wondering does anyone have an intuition as what might be wrong? There are lots of vertical white lines on most of the screen area that aren't drawable (yet some of the DLO-138 code is able to draw in this area). I tried to draw the text 400px lower and it only made the upper area black.

I tried starting fresh with original Stevestrong TFT code from Github, changing the pin values in Adafruit_TFTLCD_8bit_STM32.h
that I confirmed with schematic and very simple sketch. But I just get white screen.

Code: Select all

//src/stevestrong/Adafruit_TFTLCD_8bit_STM32.h
// from DLO-138 tft 
#define TFT_RD         PB10
#define TFT_WR         PC15
#define TFT_RS         PC14
#define TFT_CS         PC13
#define TFT_RST        PB11
My setup:
Arduino 1.8.19
Arduino SAM Boards 1.6.2
Adafruit GFX 1.2.7 (the DLO-138 code did not work for me with GFX 1.1.4 using 0x9325, I only got white screen)

Using STM32 Flash loader as I had to put AFIO_DEBUG_NONE to get the LED to blink, which made it impossible to connect via SWD pins/STlink adapter.

My test code:

Code: Select all

#include <Adafruit_GFX.h>
// i'm going to use 1.2.7 as 1.1.4 gave only white screen

#include "src/TFTLib/Adafruit_TFTLCD_8bit_STM32.h"
// from https://github.com/ardyesp/DLO-138/tree/master/src/TFTLib

// try the one from github stevestrong
//#include "src/stevestrong/Adafruit_TFTLCD_8bit_STM32.h"
// only get white screen

#define ledPin PA15

// TFT display constants
#define PORTRAIT     0
#define LANDSCAPE     3
#define TFT_WIDTH    320
#define TFT_HEIGHT    240

//in portrait 0 I get strange flickering, text begins at piscing

// need for stevestrong repo
//#define ILI9341_BLACK 0x0000
//#define ILI9341_WHITE 0xFFFF

#define ipsum "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

//--------------------led stuff
int ledState = LOW;             // ledState used to set the LED
unsigned long previousMillis = 0;        // will store last time LED was updated

#define yalign 0
// doesn't matter if unsigned int or #define
// xalign still appears ever so slightly lower
// yalign 400 you cant see the text at all, black region top

// constants won't change:
const long interval = 1000;           // interval at which to blink (milliseconds)

Adafruit_TFTLCD_8bit_STM32 tft;
 
//low bits i get text and weird blank screen bit below
//try high bits? nope i get nothing.

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);

  // try this with serial only
  afio_cfg_debug_ports(AFIO_DEBUG_NONE);
  // led works with this AFIO_DEBUG_NONE

  // init display
  tft.reset();
  // tft.begin(0x9341);
  tft.begin(0x9325);
  // 0x9325
  // 0x8357
  // 0x8347
  tft.setRotation(LANDSCAPE);
  tft.fillScreen(ILI9341_BLACK);
}

void loop() {
  tft.setCursor(0, yalign);
  tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
  tft.print(ipsum);

  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);   
  }
}
Chloe
Posts: 3
Joined: Sun Nov 12, 2023 1:50 pm

Re: STM32F103C8 and 9325 unusual display

Post by Chloe »

Small update as I think the issue is primarily with Adafruit GFX library fillScreen function not working. Other GFX functions appear to draw on the screen correctly, the screen just doesn't get refreshed properly with fillScreen.

If I understand Adafruit_TFTLCD_8bit_STM32.cpp it expects setAddrWindow? I can't call setAddrWindow directly from my main sketch loop as it crashes.

I don't honestly know where to post about it as it is not Adafruit hardware and it is old code bases.

Code: Select all

/*****************************************************************************/
// Sets the LCD address window (and address counter, on 932X).
// Relevant to rect/screen fills and H/V lines.  Input coordinates are
// assumed pre-sorted (e.g. x2 >= x1).
/*****************************************************************************/
// these are integers. -32,768 to 32,767
void Adafruit_TFTLCD_8bit_STM32::setAddrWindow(int x1, int y1, int x2, int y2)
{
  if(driver == ID_932X) {
	  ili932x_setAddrWindow(x1, y1, x2, y2);
  } else if(driver == ID_7575) {
	hx8347g_setAddrWindow(x1, y1, x2, y2);
  } else if ((driver == ID_9341) || (driver == ID_HX8357D)){
	ili9341_setAddrWindow(x1, y1, x2, y2);
  }
  // Serial.println((String)"x1: "+x1+" y1: "+y1+" x2: "+x2+" y2: "+y2);
  // can't see this at all with DEBUG_NONE and I get white screen if I try to use Serial 
}

/*****************************************************************************/
// Fast block fill operation for fillScreen, fillRect, H/V line, etc.
// Requires setAddrWindow() has previously been called to set the fill
// bounds.  'len' is inclusive, MUST be >= 1.
/*****************************************************************************/
void Adafruit_TFTLCD_8bit_STM32::flood(uint16_t color, uint32_t len) // let's try 16  uint32_t len
{
  uint16_t blocks;
  uint8_t  i, hi = color >> 8,
              lo = color;

  CS_ACTIVE;
  CD_COMMAND;
  if (driver == ID_9341) {
    write8(ILI9341_MEMORYWRITE);
  } else if (driver == ID_932X) {
    write8(0x00); // High command byte must be 0
    write8(ILI932X_RW_GRAM);
  } else if (driver == ID_HX8357D) {
    write8(HX8357_RAMWR);
  } else {
    write8(0x22); // Write data to GRAM
  }

  // Write first pixel normally, decrement counter by 1
  CD_DATA;
  write8(hi);
  write8(lo);
  len--; // i got a feeling this is it

  blocks = (uint16_t)(len / 64); // 64 pixels/block
  if(hi == lo) {
    // High and low bytes are identical.  Leave prior data
    // on the port(s) and just toggle the write strobe.
    while(blocks--) {
      i = 16; // 64 pixels/block / 4 pixels/pass
      do {
        WR_STROBE; WR_STROBE; WR_STROBE; WR_STROBE; // 2 bytes/pixel
        WR_STROBE; WR_STROBE; WR_STROBE; WR_STROBE; // x 4 pixels
      } while(--i);
    }
    // Fill any remaining pixels (1 to 64)
    for(i = (uint8_t)len & 63; i--; ) {
      WR_STROBE;
      WR_STROBE;
    }
  } else {
    while(blocks--) {
      i = 16; // 64 pixels/block / 4 pixels/pass
      do {
        write8(hi); write8(lo); write8(hi); write8(lo);
        write8(hi); write8(lo); write8(hi); write8(lo);
      } while(--i);
    }
    for(i = (uint8_t)len & 63; i--; ) {
      write8(hi);
      write8(lo);
    }
  }
  CS_IDLE;
}
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F103C8 and 9325 unusual display

Post by ag123 »

I've done something, but that it is for ILI9341 LCD
https://github.com/ag88/Adafruit_ILI9341_SPI_stm32duino
you can try adapting the codes to see if it works for your LCD. The control codes for ILI9341 vs ILI9325 are likely somewhat different, but I have not reviewed any spec sheets that provide the control commands for each LCD.
User avatar
Bakisha
Posts: 139
Joined: Fri Dec 20, 2019 6:50 pm
Answers: 5
Contact:

Re: STM32F103C8 and 9325 unusual display

Post by Bakisha »

I compiled and tested DLO-138 and it's working with my LCD. Using Rogers core, Adafruit_GFX V1.7.5.
I was unable to upload with Arduino IDE (probably WIN11 and Arduino 2.2.1 IDE issue), but with exported binary i flashed it with ST-link and STM32CubeProgrammer (tricky, press and hold reset on DSO138, click "connect", and quickly release reset).

I also tested your sketch from first post ( and files copied from \DLO-138\src\TFTLib\ ), but only

Code: Select all

 tft.begin(0x9341);
worked for me, and picture on LCD was mirrored vertically compared to yours.
Chloe
Posts: 3
Joined: Sun Nov 12, 2023 1:50 pm

Re: STM32F103C8 and 9325 unusual display

Post by Chloe »

ag123 wrote: Tue Nov 14, 2023 2:38 pm I've done something, but that it is for ILI9341 LCD
https://github.com/ag88/Adafruit_ILI9341_SPI_stm32duino
you can try adapting the codes to see if it works for your LCD. The control codes for ILI9341 vs ILI9325 are likely somewhat different, but I have not reviewed any spec sheets that provide the control commands for each LCD.
Ah nice. I was considering SPI but it seems 9325 is set up for only 3 pin/9 bit..
https://cdn-shop.adafruit.com/datasheets/ILI9325.pdf
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F103C8 and 9325 unusual display

Post by ag123 »

ok found the datasheet for ILI9341 from adafruit here as well
https://cdn-shop.adafruit.com/datasheets/ILI9341.pdf

it seemed differences are the hardware
- parallel interface
- ILI9341 has an additional led driver
- ILI9325 uses RS / RW in the control signal line(s), ILI9341 uses D/C data / command pin for control signal
but that both of them has SPI
- the control instructions / commands are after all different between them.

Hence, ILI9325 would needs its own 'driver' codes for the control instructions.
but that review Adafruit_ILI9341_STM.cpp and Adafruit_ILI9341_STM.h in my implementation
https://github.com/ag88/Adafruit_ILI934 ... 9341_STM.h
https://github.com/ag88/Adafruit_ILI934 ... 41_STM.cpp
those are mostly the overridden methods from Adafruit_GFX to implement the primitive functions needed by Adafruit_GFX to draw to the LCD.
I'd guess if you implement the equivalent for ILI9325, it should probably work the same as ILI9341
Post Reply

Return to “General discussion”