Go Down

Topic: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields (Read 515047 times) previous topic - next topic

david_prentice

Did you have an "old" library ?

Did v2.9.8 work correctly ?

Or did you need to change the REV_SCREEN attribute ?

David.


troyfletcher

Hello David,

It seems I have one of the infamous 0x3229 units

(results of readnew at bottom)

The unit is of no use to me without a valid library, and I would gladly send it to you. Please dm me or respond with the best way to reach you.



Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

diagnose any controller
reg(0x0000) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 99 99 00   Manufacturer ID
reg(0x0009) 00 00 61 00 00   Status Register
reg(0x000A) 00 08   Get Powsr Mode
reg(0x000C) 00 66   Get Pixel Format
reg(0x0030) 00 00 00 01 3F   PTLAR
reg(0x0033) 00 00 00 01 40 00 00   VSCRLDEF
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   Panel Himax HX8347-A
reg(0x00A1) 00 00 00 00 00   RD_DDB SSD1963
reg(0x00B0) 00 00   RGB Interface Signal Control
reg(0x00B3) 00 00 00 00 00   Frame Memory
reg(0x00B4) 00 00   Frame Mode
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   Panel Control
reg(0x00C1) 00 00 00 00   Display Timing
reg(0x00C5) 00 00   Frame Rate
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 00 00   Power Control
reg(0x00D1) 00 00 00 00   VCOM Control
reg(0x00D2) 00 00 00   Power Normal
reg(0x00D3) 00 00 32 29   ILI9341, ILI9488
reg(0x00D4) 00 00 00 00   Novatek
reg(0x00DA) 00 99   RDID1
reg(0x00DB) 00 99   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
reg(0x00F6) 00 00 00 00   Interface Control

david_prentice

I ordered a screen on 4 Jan.   Sometimes Aliexpress is quick.   Sometimes it is slow.   The Tracking says:
Quote
Outbound in sorting center

2020-01-12 10:45:12 [GMT+8]
Which can mean anything.    It might have an 0x3229 controller.   I will not know until it arrives.

If you are in the UK,   you can mail as a "Large Letter" if the packet is < 25mm thick.   PM me.
If you are not in the UK,   mail costs more and takes longer.

David.

troyfletcher

I ordered a screen on 4 Jan.   Sometimes Aliexpress is quick.   Sometimes it is slow.   The Tracking says:
Which can mean anything.    It might have an 0x3229 controller.   I will not know until it arrives.

If you are in the UK,   you can mail as a "Large Letter" if the packet is < 25mm thick.   PM me.
If you are not in the UK,   mail costs more and takes longer.

David.
I'm in the US, please send me an email if it's not a 0x3229 and I'll get your shipping info fletcher.troy@gmail.com

david_prentice

I will keep my fingers crossed that it is an  0x3229.

Sometimes stuff comes from China in 8-10 days.
17 days already with a stationary "Track" is not promising.   Especially since the Chinese New Year is imminent.

David.

Smurfturf

Hi, I am new here.
I have a STM32F103C8T6 (https://nl.aliexpress.com/item/32887666464.html) and one of those red-board (open-smart) touch screens (https://nl.aliexpress.com/item/32956967893.html).

I have tried a lot to get it working. In the end I had it (graphictest_kbv.ino) working through use_special and the code from the last message on https://stm32duinoforum.com/forum/viewtopic_f_9_t_4195_start_30.html (this is an archive, so I could not reply there! The special was written by altEnergy with the help of David).

I have used the pin-assignment from this last message as well. To be able to do this I had to switch pins from the lcd (d7) and the serial rx-pin on stm32-A9 for code-upload and running the code.

So, I do not know exactly what I did that I got it working, but it did. After that I started playing around with the touch-component, I did not succeed in that, but afterwards I tried the lcd again and now it did not work anymore.

I tried LCD_ID_readreg.ino with a slightly different pin assignment, so I could read the serial monitor while running it (the use_special does not allow for that, but this readreg does):
#define LCD_RST PA4
#define LCD_CS PA3
#define LCD_RS PA2
#define LCD_WR PA1
#define LCD_RD PA0
#define LCD_D0 PB10
#define LCD_D1 PB11
#define LCD_D2 PB12
#define LCD_D3 PB13
#define LCD_D4 PB14
#define LCD_D5 PB15
#define LCD_D6 PA8
// #define LCD_D7 PA9
#define LCD_D7 PA6

The output of readreg is this:
Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

reg(0x0000) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 00 00 00 00   Status Register
reg(0x000A) 00 08   Get Power Mode
reg(0x000C) 00 66   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   Panel Himax HX8347-A
reg(0x00A1) 00 01 62 83 57   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   Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA
reg(0x00CC) 00 00   Panel Control
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
reg(0x00F6) 00 00 00 00   Interface Control


I expected the 8357 at reg(0x00A1) to be seen at reg(0x0000) or am I mistaking. Because the board says "driver IC: HX8357".


I have no clue why it worked the first time, I have been playing with a lot of libraries since. like open-smart and mcufriend_kbv where I had some conflicts and deleted and reinstalled stuff to try to get it working again. I also deleted the arduino-ide-cache and such, so everything would be build fresh and not reused. All to no avail.


Does anyone have a suggestion what else I could try to get it working again? My display is now just white and no graphic test is shown.

david_prentice

From the how_to file:
Code: [Select]

HX8357-B 320x480  ID=0x8357 (shares init with 8357-D)


I strongly advise you to use the default BluePill wiring:
Code: [Select]

//LCD pins  |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 | |RD |WR |RS |CS |RST| |SD_SS|SD_DI|SD_DO|SD_SCK|
//STM32 pin |PA7|PA6|PA5|PA4|PA3|PA2|PA1|PA0| |PB0|PB6|PB7|PB8|PB9| |PA15 |PB5  |PB4  |PB3   | **ALT-SPI1**

i.e.  start from scratch with fresh libraries installed from IDE Library Manager
The default wiring should work out of the box.

If you really want to use the wiring scheme (tested and working with LCD_ID_readreg),   post your USE_SPECIAL, USE_SMURFTURF code.
Just paste the defines and the #elif block

David.

Smurfturf

Thanks for the fast reply David.

I hooked it up like you suggested.

For readreg I used the following:
#define LCD_RST PB9
#define LCD_CS PB8
#define LCD_RS PB7
#define LCD_WR PB6
#define LCD_RD PB0

#define LCD_D0 PA0
#define LCD_D1 PA1
#define LCD_D2 PA2
#define LCD_D3 PA3
#define LCD_D4 PA4
#define LCD_D5 PA5
#define LCD_D6 PA6
#define LCD_D7 PA7

The reply was:
Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

reg(0x0000) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 04 04 04 00   Manufacturer ID
reg(0x0009) 00 00 00 00 00   Status Register
reg(0x000A) 00 08   Get Power Mode
reg(0x000C) 04 04   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) 04 04   RDID1 HX8347-A
reg(0x0065) 04 04   RDID2 HX8347-A
reg(0x0066) 04 04   RDID3 HX8347-A
reg(0x0067) 04 04   RDID Himax HX8347-A
reg(0x0070) 00 00   Panel Himax HX8347-A
reg(0x00A1) 00 01 62 87 57   RD_DDB SSD1963
reg(0x00B0) 00 00   RGB Interface Signal Control
reg(0x00B4) 04 04   Inversion Control
reg(0x00B6) 04 04 04 00 04   Display Control
reg(0x00B7) 04 04   Entry Mode Set
reg(0x00BF) 00 00 00 00 00 04   ILI9481, HX8357-B
reg(0x00C0) 00 00 00 00 00 00 00 00 00   Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA
reg(0x00CC) 04 04   Panel Control
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) 04 04 04 04   Novatek ID
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 04 04   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
reg(0x00F6) 04 04 04 00   Interface Control


So the ID still did not gave 8357, so I forced it in the graphictest_kbv in the setup():
    ID = 0x8357;                             // force ID

Ì still have the white screen. I think I am still missing a define somewhere.

david_prentice

#2915 said:
Code: [Select]

reg(0x00A1) 00 01 62 83 57   RD_DDB SSD1963

#2917 said:
Code: [Select]

reg(0x00A1) 00 01 62 87 57   RD_DDB SSD1963


I have never seen a HX8357-B but a nice man from China reported:
Code: [Select]

reg(0x000A) 00 08    Get Powsr Mode
reg(0x000B) 00 00   Get Address Mode
reg(0x000C) 00 66   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 01 62 83 57 FF   RD_DDB Start
reg(0x00B0) 00 00   Command Access Protect
reg(0x00B3) 00 02 00 07 00  Frame Memory
reg(0x00B4) 00 00   Frame Mode
reg(0x00BF) 00 01 62 83 57 FF   Device Code Read
reg(0x00C0) 00 00 3B 00 02 11   Panel Control
reg(0x00C1) 00 10 17 24 Display Timing Normal
reg(0x00C2) 00 10 17 24 Display Timing Partial
reg(0x00C3) 00 00 17 24 Display Timing Idle
reg(0x00C5) 00 08   Frame Rate
reg(0x00C6) 00 02   Interface Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00  GAMMA
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 44 00 05 Power Control
reg(0x00D1) 00 48 0F 00 VCOM Control
reg(0x00D2) 00 04 12    Power Normal
reg(0x00D3) 00 04 12    Power Partial
reg(0x00D4) 00 07 12    Power Idle
reg(0x00E4) 00 2F 00 20 ? SETCABC(HX) (f.k. ILI)
reg(0x00E9) 00 00 00 00 ? Set Panel Related(HX)
reg(0x00EE) 00 2C 16 16 2C  ? Set EQ Function(HX)
reg(0x00F0) 00 00 00 00 f.k (ILI)
reg(0x00F1) 00 60   f.k
reg(0x00F2) 00 00 00 00 f.k
reg(0x00F3) 00 00 00 00 f.k (ILI)
reg(0x00F4) 00 00 00 00 f.k
reg(0x00F5) 00 00   f.k
reg(0x00F6) 00 00   f.k
reg(0x00F7) 00 00 00 00 f.k
reg(0x00F8) 00 00 00    f.k
reg(0x00F9) 00 00   f.k

You do not have 100% perfect values.   I would check your wiring carefully.   Is there something else on PA2?

David.

Smurfturf

I rewired the whole thing with different wires and the readreg gives this again:
reg(0x000A) 00 08   Get Power Mode
reg(0x000C) 00 66   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   Panel Himax HX8347-A
reg(0x00A1) 00 01 62 83 57   RD_DDB SSD1963

So it appears one of the wires was not okay.

But the graphictest_kbv still displays nothing, could it be that the LCD is (partially) fried or DOA?
I have seen it working once!

By the way, did yoy say I had to remove all libraries, or just open-smart and MCUFRIEND_kbv.

david_prentice

Personally,  I would leave the IDE.  Delete any "suspect" library directories.  Start the IDE.  Install the libraries via IDE Library Manager.

The v2.9.8 Release should work fine with an HX8357-B

The readreg sketch must be reliable.  (and correct)
If it is,  it verifies that your wiring is ok.

In which case,  all the library examples will work out of the box.

Your Red display may be made by Open-Smart but you are using the regular wiring.   Forget about any OPENSMART macros.  They do not apply to you.
Your BluePill has 3.3V logic.   It has 3.3V power pin.   So you can connect all the display pins to the BluePill.

This is in contrast to the MEGA2560 owner who is determined to connect 5V logic and 5V power (to a pin marked 3.3V)

David.

Smurfturf

When is readreg reliable then?
I now get the result like in #2915 from readreg, but that still does not return the proper ID, because mine still returns ID=0

I found in MCUFRIEND_kbv.cpp a section and I added a line to force it to think it is 8357:

uint16_t MCUFRIEND_kbv::readID(void)
{
   uint16_t ret, ret2;
   uint8_t msb;
   ret = readReg(0);           //forces a reset() if called before begin()
return 0x8357;

But then it makes my leds on my serial-programmer flash and it is spitting garbish in the serial monitor. So it must be writing to PA9 and PA10 then.

How can I force it to use the pin assignment (bluepill) proposed by you earlier? Or is this totally of track to go this route.


david_prentice

Install the libraries via IDE Library Manager.
And do not fiddle with them.

Run LCD_ID_readreg to verify your wiring.
Then run all the library examples.

Which STM32 Core are you using?
Have you fiddled with it?

David.

Smurfturf

I am using stm32 board from http://dan.drown.org/stm32duino/package_STM32duino_index.json (and I did not fiddle with that).

Oke, I will stop fiddling with it.
I just removed all libraries related to touchscreen, mcufriend, adafruit GFX and re-installed them using the library manager.

I also turned on all verbose compiler messages so I can see what the arduino-IDE is choosing.

Smurfturf

I am pulling my hairs out now, I can not make readreg anything different then in #2915.
I have been changing wires and pins and the assignments in readreg accordingly.
I even changed breadboard and I also started using an external powersupply, not just the usb-programmer anymore (I have used that on the moment that the graphictest worked as well).

I also have tested all the io pins with a led-blink to see if I had output. I did not have output on pins PA15, PB3 and PB4, but those are not in my readreg config, so that should not matter.

I need some hints what to look for now or what to try.

Go Up