prenticedavid / MCUFRIEND_kbv

MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Other
357 stars 177 forks source link

STM32F030C8T6 and a supposed S6d05A1 #253

Open leonardojc opened 3 months ago

leonardojc commented 3 months ago

Hi David. I really admire your dedication to Displays and all your work, I have used your library in many projects and they have always worked perfectly. This time I have a difficult one. and maybe you can help me.

I have this screen connected to a STM32F030C8T6 microcontroller, the display has the inscriptions TFT8K6641FPC-A1-E and TFT1P3925-E, apparently it is an S6D05A1.

I was able to verify that it is connected in 16-bit mode in Port B of the processor. (PB0-PB15) and the RST, CS, RS, WR, RD pins on PC15, PC14, PC13, PF1, PF0, but I can't know the order in which they are connected, because I don't have the display pinout. I could try different combinations to get the correct position.

I have installed STM32Duino in arduino IDE, and I can correctly program the microcontroller without problems, using a STLINK-V2.

I have tried to use your sketch but I think it is only for 8-bit. this is true?

By changing the configuration of the pins I have obtained some responses in some cases All ZEROS. but in other cases different hexadecimal values

`diagnose any controller

reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...

reg(0x0004) 04 04 04 04 Manufacturer ID

reg(0x0009) 09 09 09 09 09 Status Register

reg(0x000A) 0A 0A Get Power Mode

reg(0x000C) 0C 0C Get Pixel Format

reg(0x0030) 30 30 30 30 30 PTLAR

reg(0x0033) 33 33 33 33 33 33 33 VSCRLDEF

reg(0x0061) 61 61 RDID1 HX8347-G

reg(0x0062) 62 62 RDID2 HX8347-G

reg(0x0063) 63 63 RDID3 HX8347-G

reg(0x0064) 64 64 RDID1 HX8347-A

reg(0x0065) 65 65 RDID2 HX8347-A

reg(0x0066) 66 66 RDID3 HX8347-A

reg(0x0067) 67 67 RDID Himax HX8347-A

reg(0x0070) 70 70 Himax HX8347-A Panel

reg(0x00A1) A1 A1 A1 A1 A1 RD_DDB SSD1963

reg(0x00B0) B0 B0 RGB Interface Signal Control

reg(0x00B3) B3 B3 B3 B3 B3 Frame Memory

reg(0x00B4) B4 B4 Frame Mode`

On the other hand, I have tried to use any of the examples but I get many compilation errors, I suppose due to the lack of definition of the pins in mcufriend_special.h which I do not know how to add my Board. (GENERIC_F030C8TX)

I turn to your knowledge to make this screen work.

thank you so much

Leo

IMG-20240524-WA0010 IMG-20240524-WA0011 IMG-20240524-WA0012 IMG-20240524-WA0009

leonardojc commented 3 months ago

This is what I was able to verify in the LCD connections

Captura de pantalla 2024-05-24 120537

leonardojc commented 3 months ago

I have made a Sketch to test the 120 possible combinations of the control pins

They all result in all ZERO or the values I sent in the first post.

but one in particular gave different results, so I think it will be the right combination.

int LCD_RST = PC13; int LCD_CS = PF1; int LCD_RS = PF0; int LCD_WR = PC15; int LCD_RD = PC14;

reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ... reg(0x0004) 00 00 00 00 Manufacturer ID reg(0x0009) 00 00 71 00 00 Status Register reg(0x000A) 00 08 Get Power Mode reg(0x000C) 00 77 Get Pixel Format reg(0x0061) 00 00 RDID1 HX8347-G reg(0x0062) 00 00 RDID2 HX8347-G reg(0x0063) 00 00 RDID3 HX8347-G reg(0x0064) 00 00 RDID1 HX8347-A reg(0x0065) 00 00 RDID2 HX8347-A reg(0x0066) 00 00 RDID3 HX8347-A reg(0x0067) 00 00 RDID Himax HX8347-A reg(0x0070) 00 00 Himax HX8347-A Panel reg(0x00A1) 00 F0 F0 00 00 RD_DDB SSD1963 reg(0x00B0) 00 00 RGB Interface Signal Control reg(0x00B4) 00 00 Inversion Control reg(0x00B6) 00 00 00 00 00 Display Control reg(0x00B7) 00 00 Entry Mode Set reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B reg(0x00C0) 00 00 00 00 00 00 00 00 00 Control Panel reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA reg(0x00CC) 00 00 Control Panel reg(0x00D0) 00 00 00 Power Control reg(0x00D2) 00 00 00 00 00 NVM Read reg(0x00D3) 00 00 00 00 ILI9341, ILI9488 reg(0x00D4) 00 00 00 00 Novatek ID reg(0x00DA) 00 00 RDID1 reg(0x00DB) 00 00 RDID2 reg(0x00DC) 00 00 RDID3 reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-P reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-N reg(0x00EF) 00 00 00 00 00 00 ILI9327 reg(0x00F2) 00 00 00 00 00 00 00 00 00 00 00 00 Adjust Control 2

leonardojc commented 3 months ago

With this combination of pins I have also tried your Sketch LCD_ID_readnew.ino. with these results

mystery reg(0x0009) 00 00 71 00 00 Status Register reg(0x000A) 00 08 Get Power Mode reg(0x000B) 00 00 Get Address Mode reg(0x000C) 00 77 Get Pixel Format reg(0x000D) 00 00 Get Display Mode reg(0x000E) 00 00 Get Signal Mode reg(0x000F) 00 00 Get Diagnostic Result reg(0x00A1) 00 F0 F0 00 00 00 RD_DDB Start reg(0x00B0) 00 00 00 Command Access Protect reg(0x00BF) 00 00 00 00 00 Device Code Read reg(0x00C6) 00 00 f.k. reg(0x00D6) 00 00 00 00 f.k. reg(0x00D7) 00 00 00 00 00 f.k. reg(0x00D8) 00 00 00 00 00 f.k. reg(0x00D9) 00 00 00 00 f.k. reg(0x00E0) 00 00 f.k. reg(0x00E1) 00 E3 10 f.k. reg(0x00F0) 00 00 f.k. reg(0x00F1) 00 00 f.k. reg(0x00F2) 00 3B 40 03 08 08 00 08 00 08 08 00 f.k. reg(0x00F3) 00 03 00 00 08 00 00 00 00 f.k. reg(0x00F4) 00 00 00 00 00 00 f.k. reg(0x00F5) 00 00 00 00 00 00 04 f.k. reg(0x00F6) 00 04 00 08 07 f.k. reg(0x00F7) 00 00 80 10 02 00 00 00 00 00 00 00 00 00 00 00 f.k. reg(0x00FD) 00 00 00 00 f.k. reg(0x00FE) 00 00 f.k. reg(0x00FF) 00 00 f.k.

leonardojc commented 3 months ago

and this is the result with the options

     unlock = unlock_05A1_F0;
     for (uint16_t i = 0x00; i <= 0xFE; i++) readReg(i, 10, "f.k");

(I have eliminated the lines that only contained zeros)

reg(0x0000) 00 00 00 00 00 00 00 00 00 00 f.k

reg(0x0009) 00 00 71 00 00 00 00 00 00 00 f.k reg(0x000A) 00 08 00 00 00 00 00 00 00 00 f.k reg(0x000B) 00 00 00 00 00 00 00 00 00 00 f.k reg(0x000C) 00 77 00 00 00 00 00 00 00 00 f.k

reg(0x002E) 00 AA A6 6A 8A 71 90 C1 45 55 f.k

reg(0x003E) 00 00 00 A8 AE BA EA 0E 2E 57 f.k

reg(0x00A1) 00 F0 F0 00 00 00 00 00 00 00 f.k

reg(0x00A8) 00 F0 F0 F0 F0 F0 F0 F0 F0 F0 f.k

reg(0x00BF) 00 00 00 00 00 00 00 00 00 00 f.k reg(0x00C0) 00 80 80 10 00 00 00 00 00 00 f.k reg(0x00C1) 00 1B 00 00 00 00 00 00 00 00 f.k reg(0x00C2) 00 08 00 00 01 DF 00 00 01 3F f.k reg(0x00C3) 00 00 03 14 00 00 00 00 00 00 f.k

reg(0x00E1) 00 E3 10 1C 17 08 1D 00 00 00 f.k reg(0x00E2) 00 C3 87 39 63 D5 00 00 00 00 f.k reg(0x00E3) 00 84 06 52 00 00 00 00 00 00 f.k reg(0x00E4) 00 43 00 00 00 00 00 00 00 00 f.k reg(0x00E5) 00 00 00 00 00 00 00 00 00 00 f.k reg(0x00E6) 00 07 00 00 00 00 00 00 00 00 f.k

reg(0x00EA) 00 10 00 00 00 00 00 00 00 00 f.k

reg(0x00F2) 00 3B 40 03 08 08 00 08 00 08 f.k reg(0x00F3) 00 03 00 00 08 00 00 00 00 00 f.k reg(0x00F4) 00 00 00 00 00 00 00 00 00 04 f.k reg(0x00F5) 00 00 00 00 00 00 04 00 00 0C f.k reg(0x00F6) 00 04 00 08 07 01 00 01 20 00 f.k reg(0x00F7) 00 00 80 10 02 00 00 00 00 00 f.k reg(0x00F8) 00 11 00 18 00 00 00 00 00 00 f.k reg(0x00F9) 00 27 00 00 00 00 00 00 00 00 f.k

leonardojc commented 3 months ago

After several attempts I managed to get the display to work. (using sketch graphictest_kbv.ino) but only the blue colors are seen.

I suppose it is because I could only configure 8-bit mode. and it should be 16-bit.

I have only been able to change the pins, but I cannot modify it so that it works with 16-bit.

If you can give me a hand with this it would be great.

//############################ USE_LEODISPLAY_S6D05A1_8BIT_MODE F030    ################################
#elif defined(USE_LEODISPLAY_S6D05A1_8BIT_MODE)
#warning Using special for USE_LEODISPLAY_S6D05A1_8BIT_MODE

//LCD pins  |D15 |D14 |D13 |D12 |D11 |D10 |D9 |D8 |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |  |RD  |WR  |RS |CS |RST | 
//STM32 pin |PB15|PB14|PB13|PB12|PB11|PB10|PB9|PB8|PB7|PB6|PB5|PB4|PB3|PB2|PB1|PB0|  |PC14|PC15|PF0|PF1|PC13| 

#if defined(__STM32F1__)   //weird Maple Core
#define REGS(x) regs->x
#else                      //regular ST Core
#define REGS(x) x
#endif
#define PIN_HIGH(port, pin)   (port)-> REGS(BSRR) = (1<<(pin))
#define PIN_LOW(port, pin)    (port)-> REGS(BSRR) = (1<<((pin)+16))
#define PIN_MODE2(reg, pin, mode) reg=(reg&~(0x3<<((pin)<<1)))|(mode<<((pin)<<1))
#define GROUP_MODE(port, reg, mask, val)  {port->REGS(reg) = (port->REGS(reg) & ~(mask)) | ((mask)&(val)); }

#define WRITE_DELAY { WR_ACTIVE2; WR_ACTIVE; } //100MHz
#define READ_DELAY  { RD_ACTIVE4; RD_ACTIVE2; }

#define GPIO_INIT()   { RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN | RCC_AHBENR_GPIOCEN | RCC_AHBENR_GPIOFEN;}
#define PIN_OUTPUT(port, pin) PIN_MODE2((port)->MODER, pin, 0x1)

#define RD_PORT GPIOC
#define RD_PIN  14  
#define WR_PORT GPIOC
#define WR_PIN  15
#define CD_PORT GPIOF
#define CD_PIN  0
#define CS_PORT GPIOF
#define CS_PIN  1
#define RESET_PORT GPIOC
#define RESET_PIN  13

// configure macros for the data pins
#define write_8(d)    { GPIOB->REGS(BSRR) = 0x00FF << 16; GPIOB->REGS(BSRR) = (d) & 0xFF; }
#define read_8()      ( GPIOB->REGS(IDR) & 0xFF)
//                                        
#define setWriteDir() { setReadDir(); GPIOB->MODER |=  0x55555555; }
#define setReadDir()  { GPIOB->MODER &= ~0x55555555; }

#define write8(x)     { write_8(x); WRITE_DELAY; WR_STROBE; }
#define write16(x)    { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
#define READ_8(dst)   { RD_STROBE; READ_DELAY; dst = read_8(); RD_IDLE; }
#define READ_16(dst)  { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }

IMG-20240601-WA0002 IMG-20240601-WA0003 IMG-20240601-WA0004 IMG-20240601-WA0005

leonardojc commented 2 months ago

i made it !


#elif defined(USE_LEODISPLAY_S6D05A1_16BIT_MODE)
#warning Using special for USE_LEODISPLAY_S6D05A1_16BIT_MODE

// LCD pins  |D15 |D14 |D13 |D12 |D11 |D10 |D9 |D8 |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |  |RD  |WR  |RS |CS |RST | 
// STM32 pin |PB15|PB14|PB13|PB12|PB11|PB10|PB9 |PB8 |PB7 |PB6|PB5|PB4|PB3 |PB2 |PB1 |PB0 |  |PC14|PC15|PF0|PF1|PC13| 

#if defined(__STM32F1__)   //weird Maple Core
#define REGS(x) regs->x
#else                      //regular ST Core
#define REGS(x) x
#endif

#define PIN_HIGH(port, pin)   (port)->REGS(BSRR) = (1<<(pin))
#define PIN_LOW(port, pin)    (port)->REGS(BSRR) = (1<<((pin)+16))
#define PIN_MODE2(reg, pin, mode) reg=(reg&~(0x3<<((pin)<<1)))|(mode<<((pin)<<1))
#define GROUP_MODE(port, reg, mask, val)  {port->REGS(reg) = (port->REGS(reg) & ~(mask)) | ((mask)&(val)); }

#define WRITE_DELAY { WR_ACTIVE8; }
#define READ_DELAY  { RD_ACTIVE16; }

#define GPIO_INIT()   { \
  RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN | RCC_AHBENR_GPIOCEN | RCC_AHBENR_GPIOFEN; \
  for (int i = 0; i <= 15; i++) { PIN_OUTPUT(GPIOB, i); } \
  PIN_OUTPUT(RD_PORT, RD_PIN); \
  PIN_OUTPUT(WR_PORT, WR_PIN); \
  PIN_OUTPUT(CD_PORT, CD_PIN); \
  PIN_OUTPUT(CS_PORT, CS_PIN); \
  PIN_OUTPUT(RESET_PORT, RESET_PIN); \
}

#define PIN_OUTPUT(port, pin) PIN_MODE2((port)->MODER, pin, 0x1)

#define RD_PORT GPIOC
#define RD_PIN  14
#define WR_PORT GPIOC
#define WR_PIN  15
#define CD_PORT GPIOF
#define CD_PIN  0
#define CS_PORT GPIOF
#define CS_PIN  1
#define RESET_PORT GPIOC
#define RESET_PIN  13

#define write_16(d) { \
  GPIOB->REGS(BSRR) = 0xFFFF << 16; \
  GPIOB->REGS(BSRR) = (d) & 0xFFFF; \
}

#define read_16() (GPIOB->REGS(IDR) & 0xFFFF)

#define setWriteDir() { \
  GPIOB->MODER &= ~0xFFFFFFFF; \
  GPIOB->MODER |= 0x55555555; \
}

#define setReadDir() { \
  GPIOB->MODER &= ~0x55555555; \
}

#define USES_16BIT_BUS  //COMMENT THIS LINE IF YOU USE 8BIT BUS
#if defined(USES_16BIT_BUS)
#warning USE_DUE_16BIT_SHIELD
#define write8(x)     { write16(x & 0xFF); }
#define write16(x)    { write_16(x); WR_ACTIVE; WR_STROBE; WR_IDLE; WR_IDLE; }
#define READ_16(dst)  { RD_STROBE; RD_ACTIVE4; dst = read_16(); RD_IDLE; RD_IDLE; RD_IDLE; }
#define READ_8(dst)   { READ_16(dst); dst &= 0xFF; }
#else
#warning USE_DUE_8BIT_SHIELD
#define write8(x)     { write_8(x); WR_ACTIVE4; WR_STROBE; WR_IDLE4; }
#define write16(x)    { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
#define READ_8(dst)   { RD_STROBE; RD_ACTIVE4; dst = read_8(); RD_IDLE; RD_IDLE; RD_IDLE; }
#define READ_16(dst)  { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
#endif
// Helper macros for control pin manipulation
#define PIN_LOW(port, pin) (port)->REGS(BSRR) = (1 << ((pin) + 16))
#define PIN_HIGH(port, pin) (port)->REGS(BSRR) = (1 << (pin))
#define PIN_OUTPUT(port, pin) (port)->REGS(MODER) |= (0x1 << ((pin) * 2))
leonardojc commented 2 months ago

The board is originally from an old 3D printer, Malyan M180, maybe someone could use this old screen for an Arduino project. like me.

Imagen de WhatsApp 2024-07-03 a las 17 15 58_0105900d