STM32F103C8 & TFT (ili9325)

stm32user
Thu Nov 26, 2015 1:07 pm
Image
Stm32f103c8 Mini Board

Image
ili9325 2.4” TFT (arduino uno compotible)

HI
How do I program with these two products arduino ide

thanks!


madias
Thu Nov 26, 2015 11:41 pm
I’m sure you can use the UTFT library for the ili9325, please search the forum for a STM32duino port of UTFT.
But you have to put your hands on the lib (I assume it’s 8-bit parallel driven).

stm32user
Fri Nov 27, 2015 2:03 pm
Hi

Stm32F103C Board Pin -> TFT pin wiring diagram

Image

This connection type is correct

It also does not display a pin LCD_CD
LCD_RS same with LCD CD?
I think there’s a problem


zmemw16
Fri Nov 27, 2015 5:35 pm
swap the column headers?

look at an 8080 type interface for the control pins and use

stephen


stm32user
Fri Nov 27, 2015 7:06 pm
Can someone please link me how I wrote and which could use the library

iwalpola
Tue Jun 21, 2016 1:24 pm
Correction:
Working library: https://github.com/iwalpola/Adafruit_ILI9341_8bit_STM/
JoaoLopes’s library supports ILI9341, and this one probably is an ILI9341. I checked the SPFD5408 datasheet, and Joao’s library definitely isn’t for SPFD5408. I wonder why he named it so.

I’m in this exact same situation. Are you sure that the TFT driver IC is ILI9325?
I have seen working Arduino Uno libraries for this shield from several sources, including https://github.com/JoaoLopesF/SPFD5408. And they say that the IC is “SPFD5408”.

Joao Lopes’s library above uses a modified version of the Adafruit TFT library for the hardware layer. The Adafruit TFT library was originally for controlling ILIxxxx series of IC, but this guy modified it for the 8 bit interface of SPFD508.

Now, I’ve seen working code examples for STM32 for the ILIxxxx on Andy’s Workshop blog http://andybrown.me.uk/2012/01/01/stm32 … ft-driver/. So I’m tracking where Joao changed the Adafruit library to try and figure out how to modify an STM32 driver for this TFT.


iwalpola
Tue Jun 21, 2016 2:18 pm
Correction: The SPFD408 is compatible with ILI9341, and also in Joao’s library, there are some changes in pin_magic.h as well.
Okay, I did a git diff on the SPFD5408 library and the Adafruit TFTLCD (for ILI9325 in 8 bit mode) library. Only one thing has been changed, and that is the readID function (it reads a register to identify the chip) which isn’t a big change at all. So I think an STM32 8 bit interface library for ILI9325 should work for the SPFD5408 as well. I’ll look for one or modify andy’s workshop code.

martinayotte
Tue Jun 21, 2016 2:38 pm
I have an 3.5″ LCD from MCUFriend which looks almost the same as the one above, and I used some parallel 8bits code which use ILI9327 commands.

RogerClark
Tue Jun 21, 2016 11:00 pm
does anywhere on ebay or aliexpress sell these at reasonable prices ?

ahull
Wed Jun 22, 2016 12:34 pm
RogerClark wrote:does anywhere on ebay or aliexpress sell these at reasonable prices ?

stevestrong
Wed Jun 22, 2016 1:50 pm
2.4” + touch – spfd5408 – http://www.aliexpress.com/item/2-4-inch … 55054.html
2.8” – ILI???? – http://www.aliexpress.com/item/2-8-inch … 20242.html
3.5” – ILI9486 (parallel 16 bit) – http://www.aliexpress.com/item/Fashiona … 29793.html

RogerClark
Wed Jun 22, 2016 9:54 pm
The £3 seems reasonable to me.

The speed of 8 bit transfers opens up a lot of options


iwalpola
Sat Jun 25, 2016 4:06 pm
martinayotte wrote:I have an 3.5″ LCD from MCUFriend which looks almost the same as the one above, and I used some parallel 8bits code which use ILI9327 commands.

martinayotte
Sat Jun 25, 2016 5:37 pm
As shown in a previous post :
http://www.stm32duino.com/viewtopic.php … =637#p6641

iwalpola
Sat Jul 02, 2016 3:11 pm
Thanks martinayotte. With your help, as well as werefcat and diger67’s posts in http://www.stm32duino.com/viewtopic.php … t=10#p5835 I managed to port the SPI version of ILI9341 library to work.

viewtopic.php?f=44&t=637&p=15438#p15438

github:
https://github.com/iwalpola/Adafruit_ILI9341_8bit_STM/
demo:
https://www.youtube.com/watch?v=MAkMaZyZMWM


stevestrong
Sun Sep 04, 2016 3:35 pm
Just as info, if someone is interested, I ported the original Adafruit lib for STM32 (8bit parallel), which supports ILI9325/8 as well.
https://github.com/stevstrong/Adafruit_ … 8bit_STM32
Benchmark is available here.
And also developed a touch screen lib which has some nice features (repeated touch, double touch), check the tftpaint.ino example of the touch library for details.
https://github.com/stevstrong/TouchScreen_STM32

ili9328_small.jpg
ili9328_small.jpg (38.35 KiB) Viewed 3207 times

stevestrong
Sat Sep 10, 2016 9:12 pm
Just for fun.

RogerClark
Sat Sep 10, 2016 9:23 pm
+10

:D


ahull
Sat Sep 10, 2016 9:44 pm
RogerClark wrote:+10

:D


stevestrong
Sat Sep 10, 2016 9:51 pm
Thanks. 8-)
Now I’m looking for some really slim, small and cheap battery package, anyone already has a reference?
Idea is to marry the TFT with a good battery, use it like an arcade game console and/or power bank.
What do you think?

ahull
Sat Sep 10, 2016 10:37 pm
I’ve had good results with cheap cloned phone or camera batteries. I solder a couple of wires on to one of the equally cheap lipo charger PCBs (ebay search tp4056) and you are ready to go. Camera batteries are generally protected, and average about 800mAh. Being protected, you don’t have the worry you would have with an RC helicopter battery or an unprotected 18650. You also don’t need to worry about using the lipo charger PCB with the IC with built in protection.

Poundworld do a powerbank (for a pound obviously) which is around the 700mAh to 1000mAh marker.

https://goo.gl/photos/tPzqL6q7R9HSaSCK6

Image

https://goo.gl/photos/ECQkQ62rnNL8Pde96

Image

Here is a portable web server base on this idea, that I happened to have to hand.


RogerClark
Sun Sep 11, 2016 5:35 am
I bought a powerbank thinking I could use it with the STM32 or other projects, but the internal power sensing circuit would shut off the output after about 30 secs as it needed more than the current being drawn by the STM32 to keep it outputting.

(Also the capacity wasnt as advertised, only 2000mAH rather than 4000mAH)

So I ended up just keeping it to charge my mobile phone.

The better option is to get hold of the battery separately and also use one of those charger / regulator output modules (like in Andy’s photo), as those little modules, always have their output turned on (apart from when the battery voltage goes below a usable threshold) and they don’t have the voltage converter circuity like in the power bank, which does the buck conversion from 3.7V to 5V -, as this just wastes power as its not needed when powering the STM32


stevestrong
Sun Sep 11, 2016 7:50 am
I will try out this and this
Theoretically they should give 2500mAh, I will be satisfied if I get 1500mAh out of them, this would mean 12h of 120mA (current consumption of TFT+blue pill).

RogerClark
Sun Sep 11, 2016 11:02 am
First link didnt work for me, but I see what you mean by looking at the 2nd link.

BTW. Think someone else posted about buying batteries and expecting half the capacity they claim, but ended up with 20% of the claimed capacity :-(

Hopefully those won’t be quite as badly miss-advertised


stevestrong
Sun Sep 11, 2016 1:22 pm
I have corrected the first link, that bank is basically identical with the second one, but other supplier.
Yes, I can just hope that it will give more than 1000mAh, will see.

zmemw16
Sun Sep 11, 2016 3:15 pm
first link, cheapest is white or black, henry ford fan, so it’s black
no extra postage increase, at least for 4 off
something nicely round about £10’ish
second link, no UK delivery

stephen


Manolo88
Tue Nov 01, 2016 11:22 am
Stev,

I’m not sure routing TFT with STM32, I can’t find B2 port.

And how connect you supply??

Thanks

For Battery power bank:

You can easily use an 18650 battery. Is a lithium battery.

You can buy it at aliexpress, and a USB charger,

https://es.aliexpress.com/wholesale?cat … 50+battery

https://es.aliexpress.com/wholesale?min … roupsort=1


ahull
Tue Nov 01, 2016 11:40 am
Manolo88 wrote:
And how connect you supply??

Manolo88
Tue Nov 01, 2016 12:26 pm
Ok for the supply part.

Wich drivers are better to use an ILI93471 8 bit paralel in arduino uno shield with a Blue pill STM32f103C.

If i use a stev strong driver i dont have B2 port.

If i use a Adafruit_ILI9341_8bit_STM-master drivers doesn’t work.

Wich driver do you recomend and connection, i would like to use sd and touch.

Thanks


stevestrong
Wed Nov 02, 2016 8:32 am
PB2 was discussed here.

Manolo88
Thu Nov 03, 2016 9:25 pm
WORKING!!! TFT+Touch at the moment

Thanks to all they have contributed in this post.

Only a problem:

It doesn’t work:

Serial.println(F(“Using Adafruit 2.8\” TFT Breakout Board Pinout”)); // I must take off the “F(” and “)”
Serial.println(testRoundRects());// Funtions inside Serial.print

Do you know Why??

Thanks


zmemw16
Fri Nov 04, 2016 3:07 am
google yields this topic http://www.stm32duino.com/viewtopic.php?t=571

Manolo88
Sat Nov 05, 2016 9:06 pm
How to work with Arduino platform, STM32 cheap board and TFTShield for uno.

I will try to explain how to use a TFT for uno with tochscreen and a STM32 board.

1 Connections:

We must connect the boards in this correlation:

TFT SHIELD Port data |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |
Pin stm32 |PB7|PB6|PB5|PB4|PB3|PB2|PB1|PB0|

TFT SHIELD Control pins |RD |WR |RS |CS |RST|
Pin stm32 |PA4|PA5|PA6|PA7|PA8|
Note: PB2 is not an accesible pin, then you must connect to point marked in the image.

Pin B2.jpg
Pin B2.jpg (52.32 KiB) Viewed 2343 times

RogerClark
Sat Nov 05, 2016 9:59 pm
The F macro is not needed on the STM32 as the ARM architecture is completely different to the AVR.

However, we included the F macro (that really doesn’t do anything), but in this case it sounds like it causes some problems


david.prentice
Fri Nov 18, 2016 9:00 am
Manolo88 wrote:WORKING!!! TFT+Touch at the moment

Thanks to all they have contributed in this post.

Only a problem:

It doesn’t work:

Serial.println(F(“Using Adafruit 2.8\” TFT Breakout Board Pinout”)); // I must take off the “F(” and “)”
Serial.println(testRoundRects());// Funtions inside Serial.print

Do you know Why??

Thanks


mausi_mick
Mon Nov 21, 2016 5:13 pm
hi,

I have 3.5 inch LCD from mcufriend.com with the same pin-out (for UNO-board, ), but an ILI9327 controller for 400×240 pixel.

I have tested it with the above 8bit- lib , but without success.

I tried it with data-pins d0…d7 on PA0…PA7 and Contol-pins on PBx …
and with data-pins d0…d7 on PB0…PB7 and control-pins on PAx …,

but nothing, only a white screen !!


david.prentice
Mon Nov 21, 2016 5:59 pm
mausi_mick wrote:hi,

I have 3.5 inch LCD from mcufriend.com with the same pin-out (for UNO-board, ), but an ILI9327 controller for 400×240 pixel.

I have tested it with the above 8bit- lib , but without success.

I tried it with data-pins d0…d7 on PA0…PA7 and Contol-pins on PBx …
and with data-pins d0…d7 on PB0…PB7 and control-pins on PAx …,

but nothing, only a white screen !!


stevestrong
Mon Nov 21, 2016 5:59 pm
Can you read out the controller ID?

mausi_mick
Tue Nov 22, 2016 3:11 am
Yes, but only on the Arduino UNO

mausi_mick
Tue Nov 22, 2016 3:27 am
and here the schematic:

mcufriend-3-5-tft-uno-shield.7z
(201.63 KiB) Downloaded 247 times

david.prentice
Tue Nov 22, 2016 9:02 am
mausi_mick wrote:Yes, but only on the Arduino UNO

stevestrong
Tue Nov 22, 2016 9:19 am
mausi_mick wrote:Yes, but only on the Arduino UNO

mausi_mick
Tue Nov 22, 2016 6:37 pm
I have this program for test the ILI9327 on maple-mini:

STM32_ILI9327_graphic_01.ino
(9.01 KiB) Downloaded 144 times

david.prentice
Tue Nov 22, 2016 10:15 pm
mausi_mick wrote:I have this program for test the ILI9327 on maple-mini:

STM32_ILI9327_graphic_01.ino


stevestrong
Tue Nov 22, 2016 10:52 pm
david.prentice wrote:
I still suggest that you edit and run my LCD_ID_readreg.ino sketch. This will confirm your wiring.
The beauty of a Shield and Arduino headers is that the world can have 100% confidence in the wiring and reliable connections.

David.


mausi_mick
Wed Nov 23, 2016 3:14 am
Hi David,

here is the protocol of your program:

MCUFRIEND_REG_ID.jpg
MCUFRIEND_REG_ID.jpg (110.33 KiB) Viewed 895 times

david.prentice
Wed Nov 23, 2016 7:58 am
Your JPEG shows that you ran the sketch on a Uno.
I would like to verify that you get the same result when you run it on the Maple Mini. (edit the pin #defines in the sketch)

Likewise, please post a link to the Library .CPP file. You only supplied .H and .INO
I could then debug your Library with your sketch on my NUCLEO board. (I just need to edit the write8(), setWriteDir() … macros)

David.


mausi_mick
Wed Nov 23, 2016 8:58 am
Hi,

it’s a problem, because serial.print etc doesn’t functions on my maple mini.

Therefore better the programs:

Adafruit_TFTLCD_8bit_STM32.h
(5.89 KiB) Downloaded 88 times

stevestrong
Wed Nov 23, 2016 9:18 am
You need to run David’s sketch on maple mini.
If you have problems with Serial.print(), please remove all “F()” macros from the sketch, then it should work.

mausi_mick
Wed Nov 23, 2016 9:47 am
Super, that with or better without “F”-macro has functioned, I get id=0 for both parameters (Adafruit shield or not).

stevestrong
Wed Nov 23, 2016 9:52 am
Can you please post the printout of the serial terminal?

mausi_mick
Wed Nov 23, 2016 10:02 am
the protocol:

protocol_TFT_ILI9327_test.jpg
protocol_TFT_ILI9327_test.jpg (70.52 KiB) Viewed 385 times

stevestrong
Wed Nov 23, 2016 10:18 am
What I need is the serial protocol of David’s sketch (adapt the pin definitions to your hardware connections) running on your STM32-based hardware (maple mini?).

mausi_mick
Wed Nov 23, 2016 2:27 pm
compile and upload ? without error,

but no info on the serial monitor.


stevestrong
Wed Nov 23, 2016 2:59 pm
Are you using USB serial or SERIAL1 (or 2) with an external USB to serial converter?

mausi_mick
Wed Nov 23, 2016 3:07 pm
no,
usb is on the mini-USB adapter of the maple mini board.

stevestrong
Wed Nov 23, 2016 3:10 pm
Is any serial example sketch working on your board?

mausi_mick
Wed Nov 23, 2016 3:19 pm
I have now changed the Pins (Port B – Control, Port A – Data):

// maple UNO maple
// port Pin Pin
#define LCD_RST PB15 // A4 28
#define LCD_CS PB14 // A3 29
#define LCD_RS PB5 // A2 17
#define LCD_WR PB4 // A1 18
#define LCD_RD PB3 // A0 19

#define LCD_D0 PA0 // 8 11
#define LCD_D1 PA1 // 9 10
#define LCD_D2 PA2 // 2 9
#define LCD_D3 PA3 // 3 8
#define LCD_D4 PA4 // 4 7
#define LCD_D5 PA5 // 5 6
#define LCD_D6 PA6 // 6 5
#define LCD_D7 PA7 // 7 4

with no conflicts with USB-DP/DM (Pin23/24) and Serial1 RX/TX(Pin15/16 25/26),
but no success.


stevestrong
Wed Nov 23, 2016 3:24 pm
stevestrong wrote:Is any serial example sketch working on your board?

mausi_mick
Wed Nov 23, 2016 3:46 pm
yes, you can see it a few steps before (at12:02)

stevestrong
Wed Nov 23, 2016 3:53 pm
mausi_mick wrote:compile and upload ? without error,
but no info on the serial monitor.

david.prentice
Wed Nov 23, 2016 3:54 pm
The first job is to get your Serial working. A Maple Mini must have one USART for comms through USB.
Alternatively, you attach a USART-USB dongle to any of the 3 USARTs that seem to have 7 sets of hardware pins. (you probably don’t have all 7 on your MCU)

Having got the Serial working, you connect your Shield. And edit the readreg sketch to match your wiring.

Until you can produce a good readreg output, we will not have any confidence in your wiring.
And if you have never used “Serial”, the exercise will be invaluable to you.

David.


mausi_mick
Wed Nov 23, 2016 4:12 pm
I think I have to read the register in the loop().

It was a good idea:

LCD_ID_register_Maple_mini.jpg
LCD_ID_register_Maple_mini.jpg (192.35 KiB) Viewed 576 times

david.prentice
Wed Nov 23, 2016 5:04 pm
That verifies your wiring. Is it the same as you posted earlier?

If not, please post the actual #defines that gave the good output.

David.


mausi_mick
Wed Nov 23, 2016 5:29 pm
Hi David,

in the register_id sketch I have this defines:

//-- Arduino UNO or Mega 2560 Plugged as shield
// maple UNO maple
// port Pin Pin
#define LCD_CS PB14 // A3 29
#define LCD_RS PB5 // A2 17
#define LCD_RST PB15 // A4 28
#define LCD_WR PB4 // A1 18
#define LCD_RD PB3 // A0 19

#define LCD_D0 PA0 // 8 11
#define LCD_D1 PA1 // 9 10
#define LCD_D2 PA2 // 2 9
#define LCD_D3 PA3 // 3 8
#define LCD_D4 PA4 // 4 7
#define LCD_D5 PA5 // 5 6
#define LCD_D6 PA6 // 6 5
#define LCD_D7 PA7 // 7 4


stevestrong
Wed Nov 23, 2016 6:14 pm
As far as I can see, the ID of 0x9327 is contained in the register 0xEF.
The reading of this register is not implemented in my version, that’s why you get as ID the value 0.
You should try to force the ID as being the value 0x9325, and use this value when calling begin() in your sketch.

david.prentice
Wed Nov 23, 2016 6:21 pm
Please install the v2.9.1-Beta MCUFRIEND_kbv library from GitHub.

Then add this conditional block:
#elif defined(__STM32F1__) && defined(ARDUINO_MAPLE_MINI) // Uno Shield on MAPLE_MINI board
#warning Uno Shield on MAPLE_MINI for MAUSI_MICK
// be wise to clear all four mode bits properly.
#define GROUP_MODE(port, reg, mask, val) {port->regs->reg = (port->regs->reg & ~(mask)) | ((mask)&(val)); }
#define GP_OUT(port, reg, mask) GROUP_MODE(port, reg, mask, 0x33333333)
#define GP_INP(port, reg, mask) GROUP_MODE(port, reg, mask, 0x44444444)

#define RD_PORT GPIOB
#define RD_PIN 3
#define WR_PORT GPIOB
#define WR_PIN 4
#define CD_PORT GPIOB
#define CD_PIN 5
#define CS_PORT GPIOB
#define CS_PIN 14
#define RESET_PORT GPIOB
#define RESET_PIN 15

// configure macros for the data pins
#define write_8(d) { GPIOA->regs->BSRR = 0x00FF << 16; GPIOA->regs->BSRR = (d) & 0xFF; }
#define read_8() (GPIOA->regs->IDR & 0xFF)
// PA7 ..PA0
#define setWriteDir() {GP_OUT(GPIOA, CRL, 0xFFFFFFFF); }
#define setReadDir() {GP_INP(GPIOA, CRL, 0xFFFFFFFF); }

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

#define PIN_HIGH(port, pin) (port)->regs->BSRR = (1<<(pin))
//#define PIN_LOW(port, pin) (port)->regs->BSRR = (1<<((pin)+16))
#define PIN_LOW(port, pin) (port)->regs->ODR &= ~(1<<(pin))
// ######### changed the PIN_OUTPUT() macro ###############################################
#define PIN_OUTPUT(port, pin) gpio_set_mode(port, pin, GPIO_OUTPUT_PP) //50MHz push-pull only 0-7
#define PIN_INPUT(port, pin) gpio_set_mode(port, pin, GPIO_INPUT_FLOATING) //digital input
// ######################################################################################


mausi_mick
Wed Nov 23, 2016 7:20 pm
david ,

is the 2.9.1 the last version?

I have installed it … /hardware …/STM32F1/lib…/MCU…_kbv

But I have problems compiling the sketch , a lot of errors !


david.prentice
Wed Nov 23, 2016 7:48 pm
You need the current GitHub. I only received my NUCLEO board last week. The STM32 support is only tested on the Nucleo.

The IDE should install the Library from the ZIP into your regular Arduino libraries not into STM32.

The Orange output is basically Warnings. It should compile ok. I use v1.6.12 IDE and the ARM tools are 4.8.3-2014q1

I will post you a different PIN_OUTPUT() macro which should support the CRH register but without the Warnings.

David.


david.prentice
Wed Nov 23, 2016 8:09 pm
I have edited the earlier post. i.e. changed the macros to use the libmaple function:
#define PIN_OUTPUT(port, pin) gpio_set_mode(port, pin, GPIO_OUTPUT_PP) //50MHz push-pull only 0-7
#define PIN_INPUT(port, pin) gpio_set_mode(port, pin, GPIO_INPUT_FLOATING) //digital input

mausi_mick
Thu Nov 24, 2016 2:47 am
no success,

I changed the lib and modified
The address for TFT_CS, TFT_RD … in the sketch.

the errors:

Error_MCUFRIENDS_graphictest.ino
(34.3 KiB) Downloaded 72 times

stevestrong
Thu Nov 24, 2016 8:08 am
Have you tried my lib with forced ID = 0x9325 ?

david.prentice
Thu Nov 24, 2016 9:49 am
@mausi_mick,

My apologies. I tested STM32 with my private sketch and not the example from the library.

Yes, sure enough, STM32 barfs on icons.c i.e. a C file
My private version of icons.c has:
#if defined(__STM32F1__)
#define PROGMEM
#else
#include <Arduino.h>
#endif


stevestrong
Thu Nov 24, 2016 10:17 am
david.prentice wrote:
Incidentally, the ILI9327 is VERY different to the 9325, 9341, 8347, ….

david.prentice
Thu Nov 24, 2016 10:55 am
MIPI compliant controllers use a standard set of registers and commands for writing to the display.
User applications can work with different makes, models without any changes (except for Width and Height)

However the “Manufacturer commands” vary greatly. But as a general rule, you only use these commands at the start of an App. In fact, most displays will start up by themselves without the User touching any Manufacturer commands.

The older non-MIPI controllers like the ILI9325 are vastly different in registers, commands, initialisation, …

If you look at my Repo, you will see that there are minor differences for reading GRAM, setting orientation for MIPI controllers. i.e. “compliant” is not a magic bullet.

In practice, most Apps will only use one particular orientation and probably never read GRAM or even registers.
That is why UTFT is so effective. (and easy to add a new controller)

My Repo is due for a significant “tidy up” and a proper new Release.
If you strip out the conditional code, the basic readGRAM(), drawPixel(), setWindow(), setRotation(), vertScroll() … are fairly simple.

Maintaining separate files for 25 controllers would be a nightmare.
OTOH, if you only possess a single controller, you don’t need any conditional code.

David.


stevestrong
Thu Nov 24, 2016 12:10 pm
Thank you, David.
But, again, which initial settings of the alternatives (9341, 932x) are the best to use for 9327? Is any initial register setting needed at all?
Or is the 9327 a MIPI compliant controller which does not need any init sequence?

david.prentice
Thu Nov 24, 2016 1:58 pm
@Steve

ILI9327 is MIPI compliant 240×432 controller.
But it does have a few problems when you use PORTRAIT_REV or LANDSCAPE_REV with a 240×400 panel.

You can alter the Manufacturer registers to suit your Panel. Ilitek produce App Notes with initialisations for different Panels.

I feel really stupid. I was trying to run your library with an ILI9341. And had not looked closely at the “Adafruit” code.
It is reading the ID wrong. It is initialising wrong.

So I plugged in an ILI9325 Shield. Worked first time !!

David.

p.s. it is attempting identify a HX8357D correctly, but this code is wrong too. Where did you get your original code from?


stevestrong
Thu Nov 24, 2016 2:53 pm
david.prentice wrote:Where did you get your original code from?

david.prentice
Thu Nov 24, 2016 3:43 pm
I found https://github.com/stevstrong/Adafruit_ … _STM32.cpp with Google.
It contains:
uint16_t readReg(uint8_t r)

stevestrong
Thu Nov 24, 2016 3:57 pm
@David
Sure, your right.
But if you have a closer look, you will notice that this function is used only in one place in the original code, and at that place the return value of this function is compared with a 16 bit value.
So why to have 32 bits return value of readReg() if only 16 bits are used?
This I call code transparency and optimization.

Anyway, in your code you are using functions with return values of 24 and 40 bit width, too.
This, although it may be necessary, but is also not quite “usual” and conforming to any standard, isn’t it?
I don’t want to be picky, just to point out that one adapt the software to the actual needs. This is the basis for evolution :)

I would be more than happy if you would send me some PRs to fix some bugs or suggest improvements for the lib a forked and adapted from Adafruit.
Btw, I really appreciate your work with MCUFRIEND_kbv lib, but I wanted to keep being somehow “compliant” with original Adafruit lib.


mausi_mick
Thu Nov 24, 2016 5:15 pm
Hi David,

now I have only the problem by the compile to find the penguin in the icons.ino:

undefined reference to `penguin’

excuse me, where is the connection in the source to icons.ino ?


mausi_mick
Thu Nov 24, 2016 5:27 pm
Hi stevestrong,

I tested it with ILI9325 and changed also your .cpp file :

if ((id == 0x9325) || (id == 0x9327) || (id == 0x9328)) {
driver = ID_932X;

but no success.
But I don’t know, if I have to set TFT_DATA_NIBBLE to 0 or 8 ??
and if I have to take fast bit toggling in the .h file


david.prentice
Thu Nov 24, 2016 5:50 pm
@Steve,

If you compare the public readID() from the two libraries that I linked to, you see why you would not identify the ILI9341, ILI9327, HX8357-D

I also see why begin(0x9341) does not get very far !

There are several approaches for a TFT library:
1. individual library for each controller and interface (and possibly each platform)
2. common code with conditional modules e.g. UTFT
3. identify ID. Implement differences at runtime. e.g. Adafruit_TFTLCD, MCUFRIEND_kbv, …
4. Only identify ID. Build unique ID class with a Template. e.g. u8glib

(1) is a maintenance nightmare
(2) works ok. slow, limited functionality. wastes a lot of Flash memory on a Uno. Fine for Mega, Due, …
(3) wastes a lot of Flash memory on a Uno. Fine for Mega, Due, …
(4) relies on the punter identifying the controller.

I am happy to help with your questions. I suggest that you think through your design strategy.
The Adafruit started with HX8347 and ILI9325. The others have grown. Do you want to keep the HX8347 ?

David.


stevestrong
Thu Nov 24, 2016 7:11 pm
@David,
thanks for your comment, now I realized the mistake I made. ;)
I just corrected the readID function by replacing the “readReg()” by “readReg32()” in the github repo.
I have chosen the first strategy (the nightmare 8-), just hoping that users willing to use this lib will also contribute with at least gathering info about the controller they want to be supported. So everybody contributes with a bit of work.

@mausi_mick
Sorry, but it seems that the Adafruit lib (so as mine) is not configured to read out the ID for 9327 controller yet.
And even if it could, it seems that some more information is missing how to initialize it.
As I don’t have such a board, it would be your task to figure out what is needed to configure the chip (ask David?).
Once you have that information, I could implement it in my lib.
Btw, the data nibble should be 0 if you use the lower 8 bits (as indicated in the source code), otherwise 1.
For the first try I would use the slower method (digitalWrite). If that works, then you could try the faster method.
Please pay attention to the reset line! It is crucial that the controller gets a reset at the beginning!


david.prentice
Thu Nov 24, 2016 8:37 pm
@Steve,

Have you looked at UTFT?

It has a specific initlcd() and a setxy() for each controller. Stored on separate disk files.
And an array of sizes, interfaces for each “model”.

You can add a new controller or a new interface very easily.
You don’t even need to know too much about the initlcd() sequences.
As long as you can draw in Portrait mode, any transformations are handled in Software. e.g. LANDSCAPE

Actually, Adafruit_TFTLCD does some transformations in software. When EVERY controller is capable of drawing in hardware.

Adafruit_TFTLCD takes advantage of C++ heritability etc. e.g. graphics in Adafruit_GFX.h, printing in Print.h
And has a consistent intuitive set of method()s. UTFT is a dog’s breakfast.

If you are intending to produce separate libraries, you could do one for the (almost obsolete) ILI9325.
And concentrate standard methods for MIPI controllers in anther library. Possibly some different initlcd() i.e. begin() in Adafruit terminology

David.


mausi_mick
Fri Nov 25, 2016 3:23 am
stevestrong,

thanks for your information and your engagement.


everon
Thu Dec 01, 2016 6:27 pm
Hello

Does anyone have a library and example for STM32F103 an this diplay on picture?
Display works with the Arduino Uno and Mcufriend_kbv library.


stevestrong
Thu Dec 01, 2016 6:30 pm
If you read this thread from the beginning, you should be able to find the needed info.

michael_l
Thu Dec 01, 2016 9:40 pm
everon wrote:Hello

Does anyone have a library and example for STM32F103 an this diplay on picture?
Display works with the Arduino Uno and Mcufriend_kbv library.


david.prentice
Fri Dec 02, 2016 6:18 pm
everon wrote:Hello

Does anyone have a library and example for STM32F103 an this diplay on picture?
Display works with the Arduino Uno and Mcufriend_kbv library.


david.prentice
Fri Dec 02, 2016 6:22 pm
michael_l wrote:
I have one of these but it is 3.95″ – never tried it yet. I hope to get it working with help of this thread :-)

There are some discussions on forums that say it would have ili9488


david.prentice
Tue Dec 06, 2016 10:05 pm
My IteadMaple arrived in the post this afternoon.
I installed the Maple drivers via the Batch File in the Installation Folder.

The Bootloader would say that it had run but then whinge that it could not reset (or something).

So I changed the Linker file from ld/Flash.ld to ld/jtag.ld to make it run at 0x800000.
Attached the STLink from a NUCLEO board to the Maple SWD pins.
And upload/debug with Rowley.

Is the regular Maple bootloader supposed to be flaky? (I am using Win7-32 on a Laptop)
Should I install the “replacement” Bootloader? Does that work ok?

It is handy to debug via Rowley/STLink. But I would prefer to use a bootloader for regular sketches.

Oh, MCUFRIEND_kbv works on the IteadMaple.

David.


RogerClark
Tue Dec 06, 2016 10:59 pm
The old bootloader is normally OK, but you could also try the new one

I have an iTeadMaple but I can’t recall the last time I updated the bootloader, as I don’t use that board very much.

Note. DFU often displays an error after the upload is complete. This is a problem with DFU and not the bootloader.
The same thing happens when I use dfu-util to upload to the STM32F4 using its own built in hardware USB DFU bootloader, and I also get the same error using other people’s bootloaders (like the BlackMagic Probe dfu updater)


neresus
Mon Mar 06, 2017 1:14 am
hello

Can help me someone with wiring?
I have mcufriend 2,4″ TFT which identifiers like 0x1010
LCD D0-D7 is connected to PB0-PB7
LCD_RD – PA4
LCD_WR – PA5
LCD_RS – PA6
LCD_CS – PA7
LCD_RST – PA8

I use Adafruit_TFTLCD_8bit_STM32 from steve strong.
graphic test prints data to serial console and LCD is flickering but nothing is shown.
LCD is good I tested it on arduino uno and it works (not touch screen because I dont have time to calibrate it).


stevestrong
Mon Mar 06, 2017 9:09 am
@neresus
Please use this sketch from David (with adapted wiring) and post here the resulted serial monitor log.

Be aware that PB4 may be reserved for debug port if you upload via SWI or serial 1 (PA9/10).
For upload via USB DFU get the latest commit from the repository, in particular https://github.com/rogerclarkmelbourne/ … boards.txt.

Also, post here the header file adapted to your wiring.


neresus
Mon Mar 06, 2017 2:36 pm
stevestrong wrote:@neresus
Please use this sketch from David (with adapted wiring) and post here the resulted serial monitor log.

Be aware that PB4 may be reserved for debug port if you upload via SWI or serial 1 (PA9/10).
For upload via USB DFU get the latest commit from the repository, in particular https://github.com/rogerclarkmelbourne/ … boards.txt.

Also, post here the header file adapted to your wiring.


stevestrong
Mon Mar 06, 2017 4:31 pm
neresus wrote:reg(0x0000) 93 25 ID: ILI9320, ILI9325, ILI9335, …

neresus
Tue Mar 07, 2017 12:06 am
no luck with LCD.
I change initialization sequence but display still only flickering. On next try I will check wiring again and whole 9325 code, still hope than I miss something.

neresus
Tue Mar 07, 2017 11:47 pm
I change wiring to:
#define TFT_CNTRL_PORT GPIOB
#define LCD_RD PB3
#define LCD_WR PB4
#define LCD_RS PB5
#define LCD_CS PB6
#define LCD_RST PB7
#define TFT_DATA_PORT GPIOA

#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

and tested three different initialization sequences for older versions 9325 and still no luck with it. any suggestions someone?


stevestrong
Wed Mar 08, 2017 7:20 am
The wiring should be changed in the header file:
Adafruit_TFTLCD_8bit_STM32.h

neresus
Wed Mar 08, 2017 11:07 am
stevestrong wrote:The wiring should be changed in the header file:
Adafruit_TFTLCD_8bit_STM32.h

stevestrong
Wed Mar 08, 2017 12:56 pm
There is one more thing you should do, adapt the mask bits according to the used port pins for the control lines.
For example, TFT_RD_MASK should be BIT8 if you use PB8, TFT_WR_MASK is BIT9 if you use PB9 and so on (BITX for PBX).

neresus
Thu Mar 09, 2017 1:28 pm
stevestrong wrote:There is one more thing you should do, adapt the mask bits according to the used port pins for the control lines.
For example, TFT_RD_MASK should be BIT8 if you use PB8, TFT_WR_MASK is BIT9 if you use PB9 and so on (BITX for PBX).

stevestrong
Thu Mar 09, 2017 7:38 pm
Check the reset line.

neresus
Thu Mar 09, 2017 10:12 pm
I thing all wires are checked more than good. It is something with stm board. Because LCD is working on UNO.
I can read id of LCD but now is showing nothing.
Is some way to check whole board? I can check pins separately by connecting power on them but if is some other way..

tmk
Sun Apr 09, 2017 1:00 pm
Hello User,

I have trouble with a TFT Display: Its that:
“Elegoo 2.8” TFT Touch Screen – ILI9341″
https://www.elegoo.com/product/elegoo-u … ch-screen/

The display has 28 Pins. 8 Pins are marked as LCD_D0 to LCD_D7. Then there is LCD_RST, LCD_CS, LCD_RS, LCD_WR and LCD_RD.
3 Pins are for the power 5V, 3.3V and GND. 8 Pins seems to be unused, and there are 4 Pins for and SD Card (SD_SS, SD_DI, SD_DO and SD_SCK)

On an Uno, the display works with the elegoo lib, which is in fact the Adafruit TFT/GFX Lib.
The MCUFRIEND_kbv (Version 2.95? , there is a #define MCUFRIEND_KBV_H_ 295 in the code) also works fine.

When I put the shield on the Uno, I get:

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 61 00 00 Status Register
reg(0x000A) 00 08 Get Power Mode
reg(0x000C) 00 06 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 00 00 00 00 RD_DDB SSD1963
reg(0x00B0) 00 00 RGB Interface Signal Control
reg(0x00B4) 00 02 Inversion Control
reg(0x00B6) 00 0A 82 27 04 Display Control
reg(0x00B7) 00 06 Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B
reg(0x00C0) 00 21 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 71 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 03 03 NVM Read
reg(0x00D3) 00 00 93 41 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 0F 16 14 0A 0D 06 43 75 33 06 0E 00 0C 09 08 GAMMA-P
reg(0x00E1) 00 08 2B 2D 04 10 04 3E 24 4E 04 0F 0E 35 38 0F GAMMA-N
reg(0x00EF) 00 03 80 02 02 02 ILI9327
reg(0x00F2) 00 02 02 02 02 02 02 02 02 02 02 02 Adjust Control 2
reg(0x00F6) 00 01 00 00 Interface Control

I installed STM32Arduino and the board NUCLEO-F103RB.

When I put the display shield on the Nucleo Board, I got:
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 61 00 00 Status Register
reg(0x000A) 00 08 Get Power Mode
reg(0x000C) 00 06 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 00 00 00 00 RD_DDB SSD1963
reg(0x00B0) 00 00 RGB Interface Signal Control
reg(0x00B4) 00 02 Inversion Control
reg(0x00B6) 00 0A 82 27 04 Display Control
reg(0x00B7) 00 06 Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B
reg(0x00C0) 00 21 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 71 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 03 03 NVM Read
reg(0x00D3) 00 00 93 41 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 0F 16 14 0A 0D 06 43 75 33 06 0E 00 0C 09 08 GAMMA-P
reg(0x00E1) 00 08 2B 2D 04 10 04 3E 24 4E 04 0F 0E 35 38 0F GAMMA-N
reg(0x00EF) 00 03 80 02 02 02 ILI9327
reg(0x00F2) 00 02 02 02 02 02 02 02 02 02 02 02 Adjust Control 2
reg(0x00F6) 00 01 00 00 Interface Control

But I totally lost with any other code for the display on STM32. Not a single sketch compiles without errors. (Except the ReadRegisters above)
The example graphictest_kbv from MCUFRIEND gives:
C:\Users\[..]\MCUFRIEND_kbv\utility/mcufriend_shield.h:422:2: error: #error MCU unsupported
#error MCU unsupported

All othe libaries I tried, complain of something in libmaple:
Example:
C:\Users\[..]\Arduino\libraries\Adafruit_ILI9341_8bit_STM\Adafruit_ILI9341_8bit_STM.cpp:9:26: fatal error: libmaple/dma.h: No such file or directory

Now I am clueless. What I’am doing so wrong?


david.prentice
Sun Apr 09, 2017 2:27 pm
Which STM32 core are you using?
What is the problem with MCUFRIEND_kbv ?

I have just run graphictest_kbv with “Nucleo F103RB” from STM32F1xx Cores by ST-Microelectronics.
And with “STM Nucleo F103RB (STLink)” from the MapleCore by RogerClark et al.

MCUFRIEND_kbv looks for defined(ARDUINO_STM_NUCLEO_F103RB) || defined(ARDUINO_NUCLEO_F103RB)


tmk
Sun Apr 09, 2017 5:34 pm
david.prentice wrote:Which STM32 core are you using?
[..] You need v2.9.5-Beta for the cores from ST-Microelectronics
But the v2.9.4 Release should work with the MapleCore.

If you describe your problems, I can probably sort you out.
David.


david.prentice
Mon Apr 10, 2017 6:25 am
You are using the core from ST-Microelectronics. View Boards Manager.

Go to the Library Manager. Search for MCUFRIEND_kbv library. The Manager will tell you which version you have installed. e.g. 2.9.4

The Library Manager only installs a Release.
If you want to use a Beta version, you download the ZIP from GitHub. Then install from ZIP.

If I can ever buy a shield with a HX8357-B controller, I will test it and post a new Release.
Buying shields from Ebay is a lottery. You do not know what controller is mounted until the packet arrives. The Ebay Vendors have no idea what they are selling.

David.


stevestrong
Mon Apr 10, 2017 7:35 am
neresus wrote:But on your library cannot read LCD id, it return all the time id 0.

cab3
Mon Apr 10, 2017 9:10 pm
I’m also trying to use a ili9327 tft touchscreen with my blue pill stmf103c8.
Has there been any updates?
Has anyone got this display working in the arduino ide?

stevestrong
Mon Apr 10, 2017 9:43 pm
Have you tried the read id ino from David? Please post here the result.

david.prentice
Mon Apr 10, 2017 9:52 pm
I would certainly recommend running LCD_ID_readreg.ino sketch if you have connected the LCD_RD pin.

This will confirm your wiring. Post the list of #defines from the readreg sketch.

And quite honestly, every controller supported by MCUFRIEND_kbv should work. e.g. ILI9327
I will write the appropriate SPECIAL to match your #defines.

David.


tmk
Tue Apr 11, 2017 8:00 am
david.prentice wrote:You are using the core from ST-Microelectronics. View Boards Manager.

Go to the Library Manager. Search for MCUFRIEND_kbv library. The Manager will tell you which version you have installed. e.g. 2.9.4
The Library Manager only installs a Release.
If you want to use a Beta version, you download the ZIP from GitHub. Then install from ZIP.
David.


cab3
Tue Apr 11, 2017 10:07 am
as requested this is from the ili9327
u used davids sketch and an arduino nano

reg(0x0000) 44 44 ID: ILI9320, ILI9325, ILI9335, …
reg(0x0004) 00 54 00 00 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 00 08 Get Power Mode
reg(0x000C) 00 06 Get Pixel Format
reg(0x0061) 06 06 RDID1 HX8347-G
reg(0x0062) 06 06 RDID2 HX8347-G
reg(0x0063) 06 06 RDID3 HX8347-G
reg(0x0064) 06 06 RDID1 HX8347-A
reg(0x0065) 06 06 RDID2 HX8347-A
reg(0x0066) 06 06 RDID3 HX8347-A
reg(0x0067) 06 06 RDID Himax HX8347-A
reg(0x0070) 06 06 Panel Himax HX8347-A
reg(0x00A1) 00 00 FF 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 35 00 00 01 02 02 02 Panel Control
reg(0x00C8) 02 44 44 44 44 08 10 44 44 44 44 08 10 GAMMA
reg(0x00CC) 10 10 Panel Control
reg(0x00D0) 10 07 04 Power Control
reg(0x00D2) 04 01 44 44 44 NVM Read
reg(0x00D3) 44 01 44 44 ILI9341, ILI9488
reg(0x00D4) 44 01 44 44 Novatek ID
reg(0x00DA) 00 54 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 02 04 93 27 FF ILI9327
reg(0x00F2) FF FF FF FF FF FF FF FF FF FF FF FF Adjust Control 2
reg(0x00F6) FF FF FF FF Interface Control


stevestrong
Tue Apr 11, 2017 11:29 am
The reason for using the LCD_ID_readreg.ino sketch from David is to check the hardware connection of your target board with the display.
So we need the Davids sketch output using your STM32 board and your display.

cab3
Tue Apr 11, 2017 1:20 pm
Ok got it from stm32f103c8

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) 80 80 ID: ILI9320, ILI9325, ILI9335, …
reg(0x0004) 84 54 00 00 Manufacturer ID
reg(0x0009) 89 89 89 89 89 Status Register
reg(0x000A) 8A 8A Get Power Mode
reg(0x000C) 8C 8C Get Pixel Format
reg(0x0061) 06 06 RDID1 HX8347-G
reg(0x0062) 06 86 RDID2 HX8347-G
reg(0x0063) 06 06 RDID3 HX8347-G
reg(0x0064) 06 86 RDID1 HX8347-A
reg(0x0065) 06 86 RDID2 HX8347-A
reg(0x0066) 06 06 RDID3 HX8347-A
reg(0x0067) 06 06 RDID Himax HX8347-A
reg(0x0070) 06 06 Panel Himax HX8347-A
reg(0x00A1) 00 00 FF 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 35 00 00 01 02 02 02 Panel Control
reg(0x00C8) 02 44 44 44 44 08 10 44 44 44 44 08 10 GAMMA
reg(0x00CC) 10 10 Panel Control
reg(0x00D0) 10 10 10 Power Control
reg(0x00D2) 10 01 44 44 44 NVM Read
reg(0x00D3) 44 01 44 44 ILI9341, ILI9488
reg(0x00D4) 44 01 44 44 Novatek ID
reg(0x00DA) 00 50 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 02 04 93 27 FF ILI9327
reg(0x00F2) FF FF FF FF FF FF FF FF FF FF FF FF Adjust Control 2
reg(0x00F6) FF FF FF FF Interface Control


stevestrong
Tue Apr 11, 2017 2:10 pm
Please choose one of the threads you prefer to continue: this one or your other thread?
Double posting regarding the same issue should be avoided.

david.prentice
Tue Apr 11, 2017 2:11 pm
So all that you need to do now is quote the pin mapping defines that you used in LCD_ID_readreg sketch e.g.
//-- Arduino DUE_ELECHOUSE_SHIELD
#define LCD_RST 33 //PC1
#define LCD_CS 31 //PA7
#define LCD_RS 22 //PB26
#define LCD_WR 23 //PA14
#define LCD_RD 24 //PA15

#define LCD_D0 34 //PC2
#define LCD_D1 35
#define LCD_D2 36
#define LCD_D3 37
#define LCD_D4 38
#define LCD_D5 39
#define LCD_D6 40
#define LCD_D7 41 //PC9


cab3
Wed Apr 12, 2017 9:17 am
I used these pins

#define LCD_RST PB11
#define LCD_CS PB12
#define LCD_RS PB13
#define LCD_WR PB14
#define LCD_RD PB15

#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

whith this result

8-bit values
in special locations (first is dummy)

reg(0x0000) FF FF ID: ILI9320, ILI9325, ILI9335, …
reg(0x0004) 00 54 00 00 Manufacturer ID
reg(0x0009) 00 00 68 82 00 Status Register
reg(0x000A) 00 40 Get Power Mode
reg(0x000C) 00 06 Get Pixel Format
reg(0x0061) 06 06 RDID1 HX8347-G
reg(0x0062) 06 06 RDID2 HX8347-G
reg(0x0063) 06 06 RDID3 HX8347-G
reg(0x0064) 06 06 RDID1 HX8347-A
reg(0x0065) 06 06 RDID2 HX8347-A
reg(0x0066) 06 06 RDID3 HX8347-A
reg(0x0067) 06 06 RDID Himax HX8347-A
reg(0x0070) 06 06 Panel Himax HX8347-A
reg(0x00A1) 00 00 FF 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 35 00 00 01 02 02 02 Panel Control
reg(0x00C8) 02 44 44 44 44 08 10 44 44 44 44 08 10 GAMMA
reg(0x00CC) 10 10 Panel Control
reg(0x00D0) 10 07 04 Power Control
reg(0x00D2) 04 01 44 44 44 NVM Read
reg(0x00D3) 44 01 44 44 ILI9341, ILI9488
reg(0x00D4) 44 01 44 44 Novatek ID
reg(0x00DA) 00 54 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 02 04 93 27 FF ILI9327
reg(0x00F2) FF FF FF FF FF FF FF FF FF FF FF FF Adjust Control 2
reg(0x00F6) FF FF FF FF Interface Control


david.prentice
Wed Apr 12, 2017 12:11 pm
There is already a driver for BLUEPILL that has databus on PA0-PA7. Just change the control pins:
#define RD_PORT GPIOB
#define RD_PIN 15
#define WR_PORT GPIOB
#define WR_PIN 14
#define CD_PORT GPIOB
#define CD_PIN 13
#define CS_PORT GPIOB
#define CS_PIN 12
#define RESET_PORT GPIOB
#define RESET_PIN 11

cab3
Thu Apr 13, 2017 10:50 pm
Which library is that?

I’m wondering if anyone had any success with the ili9327 and either davids or steves library…

I’m sorry if I asked simple questions all this is very confusing to me as im not very experienced with the stm32.


VadimEL
Sun Jul 02, 2017 4:40 pm
I buy it like spfd5408 2.4 TFT touch LCD, but it ILI9325
work with Arduino uno r3 with Joao Lopes if forced tft.begin(0x9325);
================================================

ID with https://github.com/prenticedavid/MCUFRIEND_kbv

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) 93 25 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 00 00 00 Status Register
reg(0x000A) 00 00 Get Power Mode
reg(0x000C) 00 00 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 00 00 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 Panel Control
reg(0x00C8) 00 0A 00 0A 00 0A 00 0A 00 0A 00 0A 00 GAMMA
reg(0x00CC) 00 04 Panel Control
reg(0x00D0) 00 33 00 Power Control
reg(0x00D2) 00 FF 00 FF 00 NVM Read
reg(0x00D3) 00 3F 00 3F ILI9341, ILI9488
reg(0x00D4) 00 6F 00 6F 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) 12 31 12 31 12 31 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


stevestrong
Sun Jul 02, 2017 4:56 pm
This library should work with maple mini, if you adapt the wiring in the header file.

david.prentice
Sun Jul 02, 2017 9:47 pm
Use an existing wiring scheme. It should work with MapleMini.

If you want to use some different scheme, you will have to write your own SPECIAL.
Test your wiring with the LCD_ID_readreg.ino sketch.

If you have verified the wiring, I am happy to help with writing the SPECIAL.

David.


VadimEL
Mon Jul 03, 2017 7:11 pm
but where is “existing wiring scheme” ???

I test LCD_ID_readreg with MapleMini

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) 93 25 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 00 00 00 Status Register
reg(0x000A) 00 00 Get Power Mode
reg(0x000C) 00 00 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 00 00 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 Panel Control
reg(0x00C8) 00 0A 00 0A 00 0A 00 0A 00 0A 00 0A 00 GAMMA
reg(0x00CC) 00 04 Panel Control
reg(0x00D0) 00 33 00 Power Control
reg(0x00D2) 00 FF 00 FF 00 NVM Read
reg(0x00D3) 00 3F 00 3F ILI9341, ILI9488
reg(0x00D4) 00 6F 00 6F 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) 12 31 12 31 12 31 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
Mon Jul 03, 2017 7:53 pm
The library is designed for Shields. I have an IteadMaple. The Maple_Rev3 is an Arduino style board with proper Arduino headers.

Your MapleMini has no Arduino headers. It does not even have official Analog pins

If you post the defines that you have used in LCD_ID_readreg, I will know your wiring scheme and that it works! I can post a SPECIAL for you. And you can test it. The MapleMini is supported by both Roger’s MapleCore and the Core from ST.

David.


VadimEL
Tue Jul 04, 2017 8:08 am
Iteadmaple cost 33$ :lol: maplemini(STM32F103CBT6) the same hardware and cost 6$ :D
—————————————————————————————————————
//-- MAPLEMINI Plugged as shield
#define LCD_WR PA1 //10
#define LCD_RD PA0 //11
#define LCD_RST PA8 //27
#define LCD_CS PA3 //8
#define LCD_RS PA2 //9

#define LCD_D0 PB0
#define LCD_D1 PB1
#define LCD_D2 PB2
#define LCD_D3 PB3
#define LCD_D4 PB4
#define LCD_D5 PB5
#define LCD_D6 PB6
#define LCD_D7 PB7


stevestrong
Tue Jul 04, 2017 8:13 am
Vadim, have you tried my lib?
Which changes did you make there beside adapting the pins to your wiring?
What exactly is not working there?
Could you read the ID?
Can you post your code?

VadimEL
Tue Jul 04, 2017 8:48 am
yes, I try it.

connectionPORTB to DATA LCD

//Control pins |RD |WR |RS |CS |RST|
#define TFT_CNTRL_PORT GPIOA
#define TFT_RD PA0
#define TFT_WR PA1
#define TFT_RS PA2
#define TFT_CS PA3
--------------------------------------------
#define TFT_RST PB10-----> connect to PB10???


stevestrong
Tue Jul 04, 2017 8:54 am
Please note, that beside changing the pins, you also have to change the masks (couple of lines below changing the pins) in the header file.

I most likely will have to change the strategy here since I see many users confronted with the same issue.


VadimEL
Tue Jul 04, 2017 9:02 am
I do not change the pins, i use connecting scheme in Adafruit_TFTLCD_8bit_STM32.h

david.prentice
Tue Jul 04, 2017 9:33 am
@Vadim,

If you want to use MCUFRIEND_kbv please make these edits:
MCUFRIEND_kbv.h:
#elif defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_GENERIC_STM32F103V) || defined(ARDUINO_MAPLE_REV3) || defined(ARDUINO_MAPLE_MINI)
MCUFRIEND_kbv(int CS=0, int RS=0, int WR=0, int RD=0, int RST=0); //dummy arguments


stevestrong
Tue Jul 04, 2017 9:40 am
The issue must relate to inappropriate init sequence.

In my lib I use data for ILI9328, which may be different from ILI9325.
Having a look to David’s lib, the 9325 init sequence is there, and it seems that is used for both 9325 and 9328, so you could maybe import to my lib and try it out.

EDIT
Instead of reading the ID, you could set the ID in the sketch fixed to 0x9328, and begin the library with this value.


VadimEL
Tue Jul 04, 2017 11:37 am
David.
white screen :( but in arduino uno r3+this tft LCD, your lib work fine.

Serial output in graphictest_kbv
Serial took 0ms to start
ID = 0x9325


david.prentice
Tue Jul 04, 2017 12:28 pm
You appear to have done “your own” edits of mcufriend_shield.h

Since you do not have a proper “mating” shield, any special code should be in mcufriend_special.h

I have posted a test_vadim Branch on GitHub. You have to download ZIP and install from ZIP.

David.


VadimEL
Tue Jul 04, 2017 1:13 pm
David. Thanks, now mcufriend S6D0154 is work :D
I do not test touch, i connect touch like in scheme to analog pins, and test soon.
Image
=================================
mcufriend 0x9325 the same white screen :mrgreen:

david.prentice
Tue Jul 04, 2017 2:54 pm
Did you get the MapleMini going with the GitHub branch ?

I would get familiar with the basic TFT and GFX methods first. The existing TouchScreen libraries all have issues with Due, Zero, STM32, Teensy, … generally due to pinMode() and digitalWrite() “optimisations”.

I will publish a bog-standard TouchScreen_kbv version that just uses the Arduino analogRead() and digitalWrite(). It works plenty fast enough on the ARM. And quite honestly, it is not too bad on a Uno.

David.


VadimEL
Tue Jul 04, 2017 4:35 pm
I download it from your github https://github.com/prenticedavid/MCUFRI … test_vadim

saleae logic capture arduino uno r3 and maplemini (forced 0x9325 capture) http://dropmefiles.com/wdtzB

only tft.begin(9325) sequence http://dropmefiles.com/p6Rmp


bill thomson
Sun Jul 09, 2017 3:17 pm
[VadimEL – Tue Jul 04, 2017 8:08 am] –
Iteadmaple cost 33$ :lol: maplemini(STM32F103CBT6) the same hardware and cost 6$ :D
—————————————————————————————————————

The link to their new page has them listed at 5.80 USD
https://www.itead.cc/development-platfo … maple.html

I bought one about a month ago, shipping time to the US was 12 days.


VadimEL
Sun Jul 09, 2017 4:24 pm
David.

In slow 48Mhz speed it almost work =)
Image Image

=======================================
ok some how it start work well on 48Mhz, do not know why О_О
In 72Mhz – white screen after tft.begin(0x9325);
In 48Mhz – screen black after tft.begin(0x9325);
==============================================
I think truble in WriteData(dat);
Maybe it’s in MapleMini registers 72Mhz truble


david.prentice
Mon Jul 10, 2017 10:13 am
It should work quite happily at 72MHz. Your wiring must be ok. Otherwise you would get nothing at all.

I would always be happier with a Shield mating with proper Arduino header sockets.
It is electrically reliable and mechanically robust.

I solder a BluePill onto a Chinese Protoshield pcb. Solder Arduino headers. Solder wire links from BluePill to Arduino headers.
It takes a bit of time. I would prefer to buy a ready made Shield Adapter.

And hey-ho. I thought that my IteadMaple was one of the last from a discontinued production. (mine was $10 or so)
It looks as if they have found some more stock. ($5.80 is very good value)

David.


golpesar132
Mon Jul 10, 2017 1:49 pm
I have a tft lcd shield. when I run it use arduino uno, it show me that identifier is ili9325 and works well but when I run it use STM32 blue pill, and this library:
https://github.com/stevstrong/Adafruit_ … 8bit_STM32
It shows the id is ili9341 and it doesn’t work. what is the problem??? how can i solve it???

stevestrong
Mon Jul 10, 2017 2:16 pm
Please post here the serial monitor output of this example sketch from David.
Make sure that you change the used pins according to your setup using PXY format (PA2, PB14, etc.).

golpesar132
Mon Jul 10, 2017 7:27 pm
[stevestrong – Mon Jul 10, 2017 2:16 pm] –
Please post here the serial monitor output of this example sketch from David.
Make sure that you change the used pins according to your setup using PXY format (PA2, PB14, etc.).

what do you mean about changing used pins?????


stevestrong
Mon Jul 10, 2017 7:36 pm
Sorry for not being clear, I meant the pin definitions in the example sketch.

VadimEL
Mon Jul 10, 2017 7:38 pm
golpesar132 install MCUFRIEND_kbv https://github.com/prenticedavid/MCUFRIEND_kbv
use LCD_ID_readreg

Image

example to read ID of your screen. Change name of pins in example, I use in maple mini
//-- MAPLEMINI Plugged as shield
#define LCD_WR PA1 //10
#define LCD_RD PA0 //11
#define LCD_RST PA8 //27
#define LCD_CS PA3 //8
#define LCD_RS PA2 //9

#define LCD_D0 PB0
#define LCD_D1 PB1
#define LCD_D2 PB2
#define LCD_D3 PB3
#define LCD_D4 PB4
#define LCD_D5 PB5
#define LCD_D6 PB6
#define LCD_D7 PB7


golpesar132
Mon Jul 10, 2017 8:04 pm
[stevestrong – Mon Jul 10, 2017 2:16 pm] –
Please post here the serial monitor output of this example sketch from David.
Make sure that you change the used pins according to your setup using PXY format (PA2, PB14, etc.).

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) 07 70 Get Power Mode
reg(0x000C) 00 00 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 00 00 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 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

is this OK???


VadimEL
Mon Jul 10, 2017 8:05 pm
NO, check wire connection and name pins in example.

stevestrong
Mon Jul 10, 2017 8:06 pm
[golpesar132 – Mon Jul 10, 2017 8:04 pm] –
is this OK???

No, it is not OK, it seems that your wiring is not correct.
This is what you should get:
reg(0x0000) 93 25 ID: ILI9320, ILI9325, ILI9335, ...


golpesar132
Mon Jul 10, 2017 10:31 pm
I check it all. All wires and pins are Ok. What can be problem now?? It replies same…
Just one thing has value…

stevestrong
Tue Jul 11, 2017 8:48 am
Can you post a link to the LCD, where did you buy from?
Pay attention to the power supplies, Arduino boards use 5V, the STM boards are mostly using 3.3V.
Can you post a picture of your hardware setup, including the wires?

golpesar132
Tue Jul 11, 2017 10:30 am
I bought it from this link:
http://shop.aftabrayaneh.com/LCD_Monito … AFTAB.html

this is my hardware :
Image
Image

I uploaded the code on arduino uno and I got 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) 93 25 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 00 00 00 Status Register
reg(0x000A) 00 00 Get Power Mode
reg(0x000C) 00 00 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 00 00 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 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) 12 31 12 31 12 31 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


VadimEL
Tue Jul 11, 2017 11:57 am
David. :mrgreen: :mrgreen: :mrgreen:
I am happy, i found error in your code =)

Image
Image

After change this
#define WR_STROBE { WR_ACTIVE; WR_IDLE; }
to
#define WR_STROBE { WR_ACTIVE; delay_us(1); WR_IDLE; } //PWLW=TWRL=50ns
72Mhz with tft – work well. :mrgreen: :mrgreen: :mrgreen: :mrgreen:

Image

==========================
now it’s STM32 and touch screen panel issue. Then i use iwalpola lib touch work….


stevestrong
Tue Jul 11, 2017 1:20 pm
[golpesar132 – Tue Jul 11, 2017 10:30 am] –
I bought it from this link:
http://shop.aftabrayaneh.com/LCD_Monito … AFTAB.html

I think you forgot to shortcut the R4 which is connected between STM32 and the BOOT1 jumper.
This resistor is 100Kohm so that the PB2 output will not work unless you solder a bridge over this resistor (shortcut).
Please check.

Btw, as initial test, you could enable slow toggling of the control pins by enabling this line (change to “#if 1”): https://github.com/stevstrong/Adafruit_ … TM32.h#L75
If this works then you can go with the high speed version, with “#if 0”.


david.prentice
Tue Jul 11, 2017 3:25 pm
[VadimEL – Tue Jul 11, 2017 11:57 am] –
David. :mrgreen: :mrgreen: :mrgreen:
I am happy, i found error in your code =)

Image
Image

After change this
#define WR_STROBE { WR_ACTIVE; WR_IDLE; }
to
#define WR_STROBE { WR_ACTIVE; delay_us(1); WR_IDLE; } //PWLW=TWRL=50ns
72Mhz with tft – work well. :mrgreen: :mrgreen: :mrgreen: :mrgreen:

Image

==========================
now it’s STM32 and touch screen panel issue. Then i use iwalpola lib touch work….

@Vadim,

You are sampling at 2MHz. Your Saleae can only distinguish 500ns. Even then, it is always safer to sample several times in a pulse.
The whole Write Cycle must be longer than 50ns. You would need to sample at 100MHz or so.
The STM32F103 is not very fast at GPIO driving. The STM32F4xx and even STM32L4xx are much faster.

I have never attempted to use a Saleae on a parallel interface. It is not fast enough.
However, I do use the Saleae on an SPI interface. I just have to slow the SCK down to 8MHz and 24MHz sampling is ok.

I have run STM32F103 on IteadMaple, Nucleo-F103, and two BluePills. One of the BluePills has its data bus on PA0-PA7. And the Write Cycle is as short as the STM32F103 can possibly make it.

If you need to slow things down, you edit the appropriate driver in mcufriend_shield.h or mcufriend_special.h e.g.
#if defined(__STM32F1__) || defined(STM32F103xB)
#define WRITE_DELAY { WR_ACTIVE; WR_ACTIVE; } //add sufficient macros.
#define READ_DELAY { RD_ACTIVE; } //likewise. read is always much slower


VadimEL
Tue Jul 11, 2017 3:50 pm
I use delay(25) between command+data in init_table16 to understand what is the problem.

static void init_table16(const void *table, int16_t size)
{
uint16_t *p = (uint16_t *) table;

//в цикле пробегаем весь массив ILI9325_regValues[,] и отправляем поочереди то комманду то данные
while (size > 0)
{
uint16_t cmd = pgm_read_word(p++);//считать комманду
uint16_t d = pgm_read_word(p++);//считать данные

//если ожидание
if (cmd == TFTLCD_DELAY)
{
delay(d);
}
else
{
//delay(1);
CS_ACTIVE; // #define CS_ACTIVE PIN_LOW(CS_PORT, CS_PIN) LCD_CS на 0
//delay(1);
WriteCmd(cmd); //#define WriteCmd(x) { CD_COMMAND; write16(x); } // #define CD_COMMAND PIN_LOW(CD_PORT, CD_PIN) == LCD_RS на 0

//delay(1);

WriteData(d); // #define WriteData(x) { CD_DATA; write16(x); } #define CD_DATA PIN_HIGH(CD_PORT, CD_PIN) == LCD_RS на 1
//delay(1);
CS_IDLE; //CS_IDLE; //1 #define CS_IDLE PIN_HIGH(CS_PORT, CS_PIN) == LCD_CS на 1
//delay(1);

//пауза между (коммандами+данными), чтоб было видно для наглядности
delay(25);
}
size -= 2 * sizeof(int16_t);
}
}


david.prentice
Tue Jul 11, 2017 4:24 pm
My ILI9325 works fine on MY_BLUEPILL. The Adafruit Tests take 2.24 seconds @ 72MHz
My ILI9325 works fine on BLUEPILL. The Adafruit Tests take 1.39 seconds @ 72MHz
I can do the same Tests in 0.85 seconds on an overclocked Xmega. (the Xmega has got excellent PORT writes)

You appear to have introduced the delays in the tft.begin() call.

The three critical timing areas
1. drawing circles. tft.drawPixel()
2. drawing horiz and vert lines. tft.fillRect()
3. Software Scroll. tft.readGRAM()

David.


golpesar132
Tue Jul 11, 2017 4:27 pm
[stevestrong – Tue Jul 11, 2017 1:20 pm] –

[golpesar132 – Tue Jul 11, 2017 10:30 am] –
I bought it from this link:
http://shop.aftabrayaneh.com/LCD_Monito … AFTAB.html

I think you forgot to shortcut the R4 which is connected between STM32 and the BOOT1 jumper.
This resistor is 100Kohm so that the PB2 output will not work unless you solder a bridge over this resistor (shortcut).
Please check.

Btw, as initial test, you could enable slow toggling of the control pins by enabling this line (change to “#if 1”): https://github.com/stevstrong/Adafruit_ … TM32.h#L75
If this works then you can go with the high speed version, with “#if 0”.

I was unsoldered the R4 and made it short circuit.
I changed that line but it dind’nt work again. my STM32 board can has problem??


stevestrong
Tue Jul 11, 2017 5:54 pm
I would start to test each pin, whether it toggles or not.
Use a LED and connect it to each data and control pin, one after the other.
Make a short test program to toggle these pins.

VadimEL
Fri Jul 14, 2017 4:56 pm
MCUFRIEND_kbv work fine with TouchScreen_STM. :) thanks David

golpesar132
Sun Jul 16, 2017 8:17 pm
[stevestrong – Tue Jul 11, 2017 5:54 pm] –
I would start to test each pin, whether it toggles or not.
Use a LED and connect it to each data and control pin, one after the other.
Make a short test program to toggle these pins.

Thank you…
I did it. Pins PA11 PA12 PA15 PB3 PB4 didn’t toggle. I have 2 boards and I test both of them but these pins had problem in both. how can I fix it or change pins in the library????


zmemw16
Sun Jul 16, 2017 8:44 pm
PA11 & PA!2 are usb dm & dp.
PA15, PB3 & PB4 are jtag pins after reset. there is a call to disable debug on them.
btw the device data sheet is your friend and also the reference manual later on.

if you’re having issues, try using spi2 on PB12-PB15, it can handle five volt logic levels.
in the library source files, look at the constructor definitions.
stephen


golpesar132
Mon Jul 17, 2017 7:21 am
thats rigtht. I use below code and all of pins toggle after it.
but it still don’t show ant thing on the lcd. why????

VadimEL
Mon Jul 17, 2017 7:26 am
it do not show until you READ ID of screen. Use LCD_ID_readreg.ino Paste your LCD_ID_readreg.ino example and make photo of your connection to blue pill.

golpesar132
Mon Jul 17, 2017 7:37 am
I mean, I use graphicstest example. I have no ID yet in serial monitor.

golpesar132
Mon Jul 17, 2017 8:19 am
This output of code in serial monitor:
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) 93 93 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 93 93 93 93 Manufacturer ID
reg(0x0009) 93 93 93 93 93 Status Register
reg(0x000A) 93 93 Get Power Mode
reg(0x000C) 93 93 Get Pixel Format
reg(0x0061) 93 93 RDID1 HX8347-G
reg(0x0062) 93 93 RDID2 HX8347-G
reg(0x0063) 93 93 RDID3 HX8347-G
reg(0x0064) 93 93 RDID1 HX8347-A
reg(0x0065) 93 93 RDID2 HX8347-A
reg(0x0066) 93 93 RDID3 HX8347-A
reg(0x0067) 93 93 RDID Himax HX8347-A
reg(0x0070) 93 93 Panel Himax HX8347-A
reg(0x00A1) 93 93 93 93 93 RD_DDB SSD1963
reg(0x00B0) 93 93 RGB Interface Signal Control
reg(0x00B4) 93 93 Inversion Control
reg(0x00B6) 93 93 93 93 93 Display Control
reg(0x00B7) 93 93 Entry Mode Set
reg(0x00BF) 93 93 93 93 93 93 ILI9481, HX8357-B
reg(0x00C0) 93 93 93 93 93 93 93 93 93 Panel Control
reg(0x00C8) 93 93 93 93 93 93 93 93 93 93 93 93 93 GAMMA
reg(0x00CC) 93 93 Panel Control
reg(0x00D0) 93 93 93 Power Control
reg(0x00D2) 93 93 93 93 93 NVM Read
reg(0x00D3) 93 93 93 93 ILI9341, ILI9488
reg(0x00D4) 93 93 93 93 Novatek ID
reg(0x00DA) 93 93 RDID1
reg(0x00DB) 93 93 RDID2
reg(0x00DC) 93 93 RDID3
reg(0x00E0) 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 GAMMA-P
reg(0x00E1) 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 GAMMA-N
reg(0x00EF) 93 93 93 93 93 93 ILI9327
reg(0x00F2) 93 93 93 93 93 93 93 93 93 93 93 93 Adjust Control 2
reg(0x00F6) 93 93 93 93 Interface Control


VadimEL
Mon Jul 17, 2017 8:33 am
http://www.stm32duino.com/viewtopic.php … 554#p31543

Paste your LCD_ID_readreg.ino example and make photo of your connection to blue pill. Your CONNECTION IS WRONG


golpesar132
Mon Jul 17, 2017 8:45 am
[VadimEL – Mon Jul 17, 2017 8:33 am] –
http://www.stm32duino.com/viewtopic.php … 554#p31543

what???


stevestrong
Mon Jul 17, 2017 8:48 am
Don’t you think your connection is wrong, because it only reads 0x93 ?

golpesar132
Mon Jul 17, 2017 8:54 am
my connection was wrong. this is my response:
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) 07 70 Get Power Mode
reg(0x000C) 00 00 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 00 00 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 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


david.prentice
Mon Jul 17, 2017 8:56 am
The MCUFRIEND_kbv library is designed for 8-bit Shields. I know that LCD_RD is plugged into Analog #0 pin. Hence my list of #defines in the Readreg sketch.

What panel do you have?
is it a Mcufriend Uno Shield?
Or is it a 16-bit 40-pin module?

The Readreg sketch will work with MIPI controllers even if they use a 16-bit data bus. Because all “commands” operate on 8-bit.
If the ILI9325 has got a 16-bit databus, the readReg sketch will be reading the bits 15..8 of reg(0) all the time. You can re-write the readReg sketch if you want for 16-bit reads and writes.

David.

Edit. From your photo, I see that you have a Uno Shield.
I would not expect any reliable results with jumper wires. If you want to use a Shield, solder Arduino headers and links to your STM32.
If your wiring is correct, the readreg sketch should work fine. The display should work fine.


golpesar132
Mon Jul 17, 2017 9:00 am
[david.prentice – Mon Jul 17, 2017 8:56 am] –
The MCUFRIEND_kbv library is designed for 8-bit Shields. I know that LCD_RD is plugged into Analog #0 pin. Hence my list of #defines in the Readreg sketch.

What panel do you have?
is it a Mcufriend Uno Shield?
Or is it a 16-bit 40-pin module?

The Readreg sketch will work with MIPI controllers even if they use a 16-bit data bus. Because all “commands” operate on 8-bit.
If the ILI9325 has got a 16-bit databus, the readReg sketch will be reading the bits 15..8 of reg(0) all the time. You can re-write the readReg sketch if you want for 16-bit reads and writes.

David.

I have Mcufriend Uno Shield and it is 8 bits. I send its picture.
I use this code on arduino uno, and that show me the ID is 9325.


golpesar132
Mon Jul 17, 2017 10:26 am
when I use this code:
afio_cfg_debug_ports(AFIO_DEBUG_NONE);

stevestrong
Mon Jul 17, 2017 11:09 am
[golpesar132 – Mon Jul 17, 2017 7:21 am] –
thats rigtht. I use below code and all of pins toggle after it.
but it still don’t show ant thing on the lcd. why????

Your information is many times confusing:
– how did the pins toggle if you have not used “afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY);” before?

Anyway, now that is clear you have an ILI9326, you should be able to use any display lib you want.


david.prentice
Mon Jul 17, 2017 11:28 am
I prefer to use the ST core. However it does not initialise PB4 in its init() code.
The Maple core does.

If MCUFRIEND_kbv is running on the ST core, it enables the PB4 pin.

What is a complete mystery: the Shield returns ID = 0x9325 on a Uno and ID = 0x9326 on MapleMini.

The ILI9326 is a 240×400 with VERY different registers to a 240×320 ILI9325.

From memory, I posted a SPECIAL for golpesar123. So I would expect MCUFRIEND_kbv to work out of the box. Note that you should enable support for ILI9326 and SPFD5420:
#define SUPPORT_9326_5420


golpesar132
Thu Jul 20, 2017 6:08 pm
Thank you all guys. my problem is solved.
Now I have problem with tftbmp example. after I add the following code to the Adafruit_TFTLCD_8bit_STM32.h file:
uint16_t color565(uint8_t r, uint8_t g, uint8_t b)

stevestrong
Thu Jul 20, 2017 7:01 pm
Your LCD pin settings in the sketch are not relevant. Only what in the “Adafruit_TFTLCD_8bit_STM32.h” header file is set, is relevant.
So please set there the LCD pins (and the mask values as well).
Also, don´t forget to allocate the LCD_RST pin, it is important that the LCD get reset.

To be sure that the display works correctly, try a simple example, like drawing a red filled rectangle at the coordinates (50, 100) and see if it works.


david.prentice
Thu Jul 20, 2017 7:59 pm
I would start with a bit of honesty. i.e. do you have a 240×320 ILI9325 or a 240×400 ILI9326.

Your photo does look like a 240×320. You did say the ID was reported as 0x9325 on a Uno.
But your earlier message showed LCD_readreg.ino with reg(0) returning 0x9326 on the STM32.

It is very straightforward to render a 24-bit BMP from SD card. Most libraries have examples.
Your SD is obviously working fine. It looks as if your tft.setAddrWindow() or tft.pushColors() is not working properly.

Incidentally, I spent some minutes of my life writing a SPECIAL for you.
It would be nice to get some feedback.

David.


golpesar132
Thu Jul 20, 2017 8:49 pm
sorry guys, if I can’t explain good

Your LCD pin settings in the sketch are not relevant. Only what in the “Adafruit_TFTLCD_8bit_STM32.h” header file is set, is relevant.
So please set there the LCD pins (and the mask values as well).
Also, don´t forget to allocate the LCD_RST pin, it is important that the LCD get reset.

To be sure that the display works correctly, try a simple example, like drawing a red filled rectangle at the coordinates (50, 100) and see if it works.
graphicstest example works well and show all rectangle, circles and ….
it means all of my pins connection is correct.

I would start with a bit of honesty. i.e. do you have a 240×320 ILI9325 or a 240×400 ILI9326.

Your photo does look like a 240×320. You did say the ID was reported as 0x9325 on a Uno.
But your earlier message showed LCD_readreg.ino with reg(0) returning 0x9326 on the STM32.
I don’t know why I got those feedback a couple of times but the LCD reg is 0x9325 and now the LCD show me that.

It is very straightforward to render a 24-bit BMP from SD card. Most libraries have examples.
Your SD is obviously working fine. It looks as if your tft.setAddrWindow() or tft.pushColors() is not working properly.

I think must be right, tft.pushColors() must have some problem. because I think tft.setAddrWindow() but color don’t show correct.
how can i find out that’s true and how can i fix it?


stevestrong
Thu Jul 20, 2017 9:29 pm
OK, so if graphicstest runs well, setAddressWndow() sould also be ok, then it most probably has to do with the BMP example.

Better said, a function involved by the BMP example, but not involved in graphicstest, is probably the reason.


golpesar132
Thu Jul 20, 2017 9:34 pm
[stevestrong – Thu Jul 20, 2017 9:29 pm] –
OK, so if graphicstest runs well, setAddressWndow() sould also be ok, then it most probably has to do with the BMP example.

Better said, a function involved by the BMP example, but not involved in graphicstest, is probably the reason.

which function for example???


david.prentice
Thu Jul 20, 2017 11:11 pm
Adafruit_TFTLCD_STM is not installed with the Core. And is not available from the Library Manager.

Post a link to the actual library you are using. And either say which example you are using or attach your actual showBMP sketch.

The regular Adafruit graphicstest sketch does not test the pushColors() method. But it is easy enough to write your own test.
But the most important first step is: study the graphicstest sketch carefully. Make notes about any wrong colours or bad shapes.

It is important that Adafruit or any library author gets feedback when there is a problem. However small.
You may want other members to replicate your problem before contacting a big company. It is only polite and they will take more notice of a group of users.

David.


golpesar132
Fri Jul 21, 2017 6:23 am
I use this library:
https://github.com/stevstrong/Adafruit_ … 8bit_STM32

and this is my code:
// BMP-loading example specifically for the TFTLCD breakout board.
// If using the Arduino shield, use the tftbmp_shield.pde sketch instead!
// If using an Arduino Mega make sure to use its hardware SPI pins, OR make
// sure the SD library is configured for 'soft' SPI in the file Sd2Card.h.

#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD_8bit_STM32.h> // Hardware-specific library

#include <SD.h>
#include <SPI.h>

// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
#define LCD_CS PA3 // Chip Select goes to Analog 3
#define LCD_CD PA2 // Command/Data goes to Analog 2
#define LCD_WR PA1 // LCD Write goes to Analog 1
#define LCD_RD PA0 // LCD Read goes to Analog 0

// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
// D0 connects to digital pin 8 (Notice these are
// D1 connects to digital pin 9 NOT in order!)
// D2 connects to digital pin 2
// D3 connects to digital pin 3
// D4 connects to digital pin 4
// D5 connects to digital pin 5
// D6 connects to digital pin 6
// D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).

// For Arduino Uno/Duemilanove, etc
// connect the SD card with DI going to pin 11, DO going to pin 12 and SCK going to pin 13 (standard)
// Then pin 10 goes to CS (or whatever you have set up)
#define SD_CS PA4 // Set the chip select line to whatever you use (10 doesnt conflict with the library)

// In the SD card, place 24 bit color BMP files (be sure they are 24-bit!)
// There are examples in the sketch folder

// our TFT wiring
/*
extern Adafruit_TFTLCD_8bit_STM32 TFT;
#define tft TFT
*/
Adafruit_TFTLCD_8bit_STM32 tft;

void setup()
{
afio_cfg_debug_ports(AFIO_DEBUG_NONE);
Serial.begin(115200);
while ( !Serial.isConnected() ) ;
tft.reset();

uint16_t identifier = tft.readID();

if(identifier == 0x9325) {
Serial.println(F("Found ILI9325 LCD driver"));
} else if(identifier == 0x9328) {
Serial.println(F("Found ILI9328 LCD driver"));
} else if(identifier == 0x7575) {
Serial.println(F("Found HX8347G LCD driver"));
} else if(identifier == 0x9341) {
Serial.println(F("Found ILI9341 LCD driver"));
} else if(identifier == 0x8357) {
Serial.println(F("Found HX8357D LCD driver"));
} else {
Serial.print(F("Unknown LCD driver chip: "));
Serial.println(identifier, HEX);
Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
Serial.println(F("If using the breakout board, it should NOT be #defined!"));
Serial.println(F("Also if using the breakout, double-check that all wiring"));
Serial.println(F("matches the tutorial."));
return;
}

tft.begin(identifier);

Serial.print(F("Initializing SD card..."));
if (!SD.begin(SD_CS)) {
Serial.println(F("failed!"));
return;
}
Serial.println(F("OK!"));

bmpDraw("normal.bmp", 0, 0);
delay(1000);
}

void loop()
{
for(int i = 0; i<4; i++) {
tft.setRotation(i);
tft.fillScreen(0);
for(int j=0; j <= 200; j += 50) {
bmpDraw("miniwoof.bmp", j, j);
}
delay(1000);
}
}

// This function opens a Windows Bitmap (BMP) file and
// displays it at the given coordinates. It's sped up
// by reading many pixels worth of data at a time
// (rather than pixel by pixel). Increasing the buffer
// size takes more of the Arduino's precious RAM but
// makes loading a little faster. 20 pixels seems a
// good balance.

#define BUFFPIXEL 20

void bmpDraw(char *filename, int x, int y) {

File bmpFile;
int bmpWidth, bmpHeight; // W+H in pixels
uint8_t bmpDepth; // Bit depth (currently must be 24)
uint32_t bmpImageoffset; // Start of image data in file
uint32_t rowSize; // Not always = bmpWidth; may have padding
uint8_t sdbuffer[3*BUFFPIXEL]; // pixel in buffer (R+G+B per pixel)
uint16_t lcdbuffer[BUFFPIXEL]; // pixel out buffer (16-bit per pixel)
uint8_t buffidx = sizeof(sdbuffer); // Current position in sdbuffer
boolean goodBmp = false; // Set to true on valid header parse
boolean flip = true; // BMP is stored bottom-to-top
int w, h, row, col;
uint8_t r, g, b;
uint32_t pos = 0, startTime = millis();
uint8_t lcdidx = 0;
boolean first = true;

if((x >= tft.width()) || (y >= tft.height())) return;

Serial.println();
Serial.print(F("Loading image '"));
Serial.print(filename);
Serial.println('\'');
// Open requested file on SD card
if ((bmpFile = SD.open(filename)) == NULL) {
Serial.println(F("File not found"));
return;
}

// Parse BMP header
if(read16(bmpFile) == 0x4D42) { // BMP signature
Serial.println(F("File size: ")); Serial.println(read32(bmpFile));
(void)read32(bmpFile); // Read & ignore creator bytes
bmpImageoffset = read32(bmpFile); // Start of image data
Serial.print(F("Image Offset: ")); Serial.println(bmpImageoffset, DEC);
// Read DIB header
Serial.print(F("Header size: ")); Serial.println(read32(bmpFile));
bmpWidth = read32(bmpFile);
bmpHeight = read32(bmpFile);
if(read16(bmpFile) == 1) { // # planes -- must be '1'
bmpDepth = read16(bmpFile); // bits per pixel
Serial.print(F("Bit Depth: ")); Serial.println(bmpDepth);
if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed

goodBmp = true; // Supported BMP format -- proceed!
Serial.print(F("Image size: "));
Serial.print(bmpWidth);
Serial.print('x');
Serial.println(bmpHeight);

// BMP rows are padded (if needed) to 4-byte boundary
rowSize = (bmpWidth * 3 + 3) & ~3;

// If bmpHeight is negative, image is in top-down order.
// This is not canon but has been observed in the wild.
if(bmpHeight < 0) {
bmpHeight = -bmpHeight;
flip = false;
}

// Crop area to be loaded
w = bmpWidth;
h = bmpHeight;
if((x+w-1) >= tft.width()) w = tft.width() - x;
if((y+h-1) >= tft.height()) h = tft.height() - y;

// Set TFT address window to clipped image bounds
tft.setAddrWindow(x, y, x+w-1, y+h-1);

for (row=0; row<h; row++) { // For each scanline...
// Seek to start of scan line. It might seem labor-
// intensive to be doing this on every line, but this
// method covers a lot of gritty details like cropping
// and scanline padding. Also, the seek only takes
// place if the file position actually needs to change
// (avoids a lot of cluster math in SD library).
if(flip) // Bitmap is stored bottom-to-top order (normal BMP)
pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
else // Bitmap is stored top-to-bottom
pos = bmpImageoffset + row * rowSize;
if(bmpFile.position() != pos) { // Need seek?
bmpFile.seek(pos);
buffidx = sizeof(sdbuffer); // Force buffer reload
}

for (col=0; col<w; col++) { // For each column...
// Time to read more pixel data?
if (buffidx >= sizeof(sdbuffer)) { // Indeed
// Push LCD buffer to the display first
if(lcdidx > 0) {
tft.pushColors(lcdbuffer, lcdidx, first);
lcdidx = 0;
first = false;
}
bmpFile.read(sdbuffer, sizeof(sdbuffer));
buffidx = 0; // Set index to beginning
}

// Convert pixel from BMP to TFT format
b = sdbuffer[buffidx++];
g = sdbuffer[buffidx++];
r = sdbuffer[buffidx++];
lcdbuffer[lcdidx++] = tft.color565(r,g,b);
} // end pixel
} // end scanline
// Write any remaining data to LCD
if(lcdidx > 0) {
tft.pushColors(lcdbuffer, lcdidx, first);
}
Serial.print(F("Loaded in "));
Serial.print(millis() - startTime);
Serial.println(" ms");
} // end goodBmp
}
}

bmpFile.close();
if(!goodBmp) Serial.println(F("BMP format not recognized."));
}

// These read 16- and 32-bit types from the SD card file.
// BMP data is stored little-endian, Arduino is little-endian too.
// May need to reverse subscript order if porting elsewhere.

uint16_t read16(File f) {
uint16_t result;
((uint8_t *)&result)[0] = f.read(); // LSB
((uint8_t *)&result)[1] = f.read(); // MSB
return result;
}

uint32_t read32(File f) {
uint32_t result;
((uint8_t *)&result)[0] = f.read(); // LSB
((uint8_t *)&result)[1] = f.read();
((uint8_t *)&result)[2] = f.read();
((uint8_t *)&result)[3] = f.read(); // MSB
return result;
}


david.prentice
Fri Jul 21, 2017 3:38 pm
I installed Steve’s library and modified for my GPIO usage.

Steve’s library only works with the Maple Core. Not with the ST Core.

Anyway, Steve’s library code for pushColors() and setWindow() looks absolutely fine.
Here is a test sketch to prove it (tested on a BluePill):
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD_8bit_STM32.h> // Hardware-specific library

Adafruit_TFTLCD_8bit_STM32 tft;

#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

void setup(void) {
afio_cfg_debug_ports(AFIO_DEBUG_NONE);
Serial.begin(9600);
while ( !Serial.isConnected() ) ;
delay(1000);

Serial.println(F("pushColors() test"));

tft.reset();
uint16_t ID = tft.readID();
// ID = 0x9325;
Serial.print(F("ID = 0x"));
Serial.println(ID, HEX);
tft.begin(ID);
tft.fillScreen(BLACK);
tft.setTextColor(YELLOW, BLACK);
tft.setTextSize(2);
}

uint16_t scrollbuf[320]; // Adafruit only does 240x320
// Adafruit can read a block by one pixel at a time
int16_t READGRAM(int16_t x, int16_t y, uint16_t *block, int16_t w, int16_t h)
{
uint16_t *p;
for (int row = 0; row < h; row++) {
p = block + row * w;
for (int col = 0; col < w; col++) {
*p++ = tft.readPixel(x + col, y + row);
}
}
}

void windowScroll(int16_t x, int16_t y, int16_t wid, int16_t ht, int16_t dx, int16_t dy, uint16_t *buf)
{
if (dx) for (int16_t row = 0; row < ht; row++) {
READGRAM(x, y + row, buf, wid, 1);
tft.setAddrWindow(x, y + row, x + wid - 1, y + row);
tft.pushColors(buf + dx, wid - dx, 1);
tft.pushColors(buf + 0, dx, 0);
}
if (dy) for (int16_t col = 0; col < wid; col++) {
READGRAM(x + col, y, buf, 1, ht);
tft.setAddrWindow(x + col, y, x + col, y + ht - 1);
tft.pushColors(buf + dy, ht - dy, 1);
tft.pushColors(buf + 0, dy, 0);
}
}

void loop()
{
int wid = tft.width(), n;
tft.setCursor(0, 200);
tft.print("SOFTWARE SCROLL ");
// scroll a whole width of the screen
n = (wid > 320) ? 320 : wid;
for (int16_t i = n, dx = 4, dy = 0; i > 0; i -= dx) {
windowScroll(0, 200, n, 16, dx, dy, scrollbuf);
}
delay(5000);
}


golpesar132
Fri Jul 21, 2017 4:42 pm
what must be the output of your code?? It is a text that change position and change color to yellow and blue??

How can I use MCUFRIEND_kbv library?? How is its wiring??


david.prentice
Fri Jul 21, 2017 9:38 pm
You have a regular Uno Shield. Plug it into a Uno.
Install MCUFRIEND_kbv with the Library Manager. Run the examples.
You will see what “SOFTWARE SCROLL” does on the Uno.

The YELLOW text moves across the screen. There should not be any BLUE at all.

I am sure that Steve’s library will work just fine on the STM32.
If Steve’s examples work, so should any other sketches.

MCUFRIEND_kbv works out of the box on a NUCLEO-F103 or NUCLEO-L476
MCUFRIEND_kbv expects the data bus on PA0..PA7. Control signals on PB5..PB9 for a BLUEPILL

I could post you an MCUFRIEND_kbv SPECIAL that matches Steve’s wiring, but I suggest that you continue with Steve’s Library. e.g. re-install.

David.


golpesar132
Sun Jul 23, 2017 2:58 pm
Thank you. I did it use Steve’s library.

golpesar132
Sun Jul 23, 2017 6:54 pm
If we use that bmp show example, the speed will be really low. is there any way to increase the speed. for example if we save the image in an array and use drawbitmap(), the image will be shown immediately. is there any way to show an image from SD card, fast like that???

stevestrong
Mon Jul 24, 2017 11:32 am
I am almost sure that I tested the BMP example reading a file from SD card, but I will check it again.

golpesar132
Mon Jul 24, 2017 11:41 am
[stevestrong – Mon Jul 24, 2017 11:32 am] –
I am almost sure that I tested the BMP example reading a file from SD card, but I will check it again.

I am ok with that example. but it is very slow. I want to load it faster like birduino example images, but an image like that is too big and I cant have it on the flash memory of microcontroller. how can I do it faster from sd card?


stevestrong
Mon Jul 24, 2017 11:56 am
1. faster reading from card
If you are using the SD card only for reading, then you could use the SdFatEX class (search the SDFat lib for that information, and/or the forum) or use at least a 4kB buffer.
viewtopic.php?f=51&t=2034&p=27982&hilit=sdfatex#p27982

2. parallel processing
– You could (theoretically) use an asynchronous DMA access to send the data to LCD while the new data is read form the SD card.
I don’t have any DMA example which would send parallel data to a GPIO port, but I am interested to see one working with an LCD.
– Another alternative for this is using FreeRTOS – again, I did not use it so far, so cannot provide any support.
– still another potential could be exploited if the SdFat lib would use yield() for the time is waiting for a process to complete…(which is the case for the SDIO lib for F4, but not for SPI)

3. use another chip with more FLASH memory – where you can fit all needed bitmaps in the FLASH.
Btw, it may happen that the F103C8 chip includes 128kB flash instead of the officially specified 64kB.


david.prentice
Mon Jul 24, 2017 1:07 pm
If you want the fastest rendering of a BMP from SD card:
1. pre-process the BMP files into RAW data e.g. like UTFT utility.
2. set a rectangular window with the correct dimensions.
3. read the raw pixel data from SD with a DMA version of SD.h library.
4. blit the pixel data to the screen. e.g. with pushColors()
5. if you arrange (3) and (4) to run simultaneously, you will effectively fill the screen as fast as your SPI rate from the SD.

6. as Steve has suggested, if you can use a SDIO interface to the SD, it will be faster than SPI.
7. this needs access to all the SD pins and a CPU with SDIO hardware.

I assume that you have got Steve’s library working ok now.
What was the problem?

David.


golpesar132
Mon Jul 24, 2017 1:16 pm
Thank you. I will test these.

[david.prentice – Mon Jul 24, 2017 1:07 pm] –
1. pre-process the BMP files into RAW data e.g. like UTFT utility.

how can i do this?? and then how can i read it?

[david.prentice – Mon Jul 24, 2017 1:07 pm] –
I assume that you have got Steve’s library working ok now.
What was the problem?

the color565 wasn’t in the class in that library. just we should use color565() instead of tft.color565().


nopnop2002
Mon Apr 02, 2018 1:41 am
[david.prentice – Tue May 23, 2017 11:35 am] –

There will be other libraries that might support the LGDP4535.

I plan to add LGDP4535 to the support list.

https://github.com/nopnop2002/STM32_TFT_8bit


stevestrong
Mon Apr 02, 2018 9:36 am
I moved the last post here as it seemed to be related to 8 bit lib.

nopnop2002
Mon Apr 02, 2018 1:42 pm
[stevestrong – Mon Apr 02, 2018 9:36 am] –
I moved the last post here as it seemed to be related to 8 bit lib.

@stevestrong
Thank you.

I added LGDP4535.
But i don’t have this one.
So I can’t test.


sompost
Sun Apr 08, 2018 9:01 am
Stupid question: Does it matter that the STM32 board outputs only 3.3V while the display expects 5V?
I saw a video of a guy suggesting to supply 3.3V everywhere (especially to the 5V pin) and then shorting the in and out pins of the display’s on-board regulator.

Perhaps I’m just wiring it wrong, but I only get a white screen (I’m using PA0..7 as data pins and PB10..12 for control).

Ralph


stevestrong
Sun Apr 08, 2018 12:00 pm
Have you set correctly the header file according to your connections?
Have you tested the connections with the example from David?
It make sense to feed the display with 5V because the regulator on blue pill is not strong enough to deliver the necessary current for the background light of the LCD.

sompost
Sun Apr 08, 2018 3:36 pm
Thanks four your prompt reply — on a sunday!

Stupid me: I failed to connect the read line (that I don’t use). Oh antenna…. :oops: After I did (connect), it does (work)!

Thanks again, Ralph


Leave a Reply

Your email address will not be published. Required fields are marked *