[SOLVED] SMT32F103C + ILI9486 TFT not working!

ericosowski
Sun Oct 28, 2018 4:41 pm
Hello guys,
I’m new with STM32 and I’m in trouble with a TFT 3.5″ UNO SHIELD as show at the attached image, like another topics, the tft works fine with arduino + MCUFRIEND_kbv library, but with SMT32 blue pill doesn’t work.
I read a couple of topics but none was solution for my case!
Also, I already made the test LCD_ID_Reader using the follow pins

#define LCD_RST PB9
#define LCD_CS PB8
#define LCD_RS PB7
#define LCD_WR PB6
#define LCD_RD PB5

#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


stevestrong
Sun Oct 28, 2018 9:03 pm
@eric,
as reply to your introductory post you have been given a link.
Read carefully that link and please post some more information like:

which core?
which library have you tried?
Example code?
What exactly means “not working”?

Search the posts where David Prentice was involved, you should find a “special” made by him, you just have to adapt to your pinning for the solution.


ericosowski
Sun Oct 28, 2018 10:57 pm
Believe me, I read almost all topics about tft and David Prentice tips, but I didn’t get to go any further with my lcd tft for arduino.
I’m trying to use the MCUFRIEND_kbv and Adafruit_TFTLCD_8bit_STM32 with no sucess.

When I sayed “not working” is because the tft only shows white screen even tryng to use the exemple UTFT_Demo_480x320 from MCUFRIEND_kbv, but the wiring is correct because it’s reading the screen id when using the exemple LCD_ID_readreg from MCUFRIEND_kbvm wich is ILI9486.

Using arduino uno it works with MCUFRIEND_kbv library, but when I try with SMT32F103C8t6 is just white screen.
The example code is the same examples from MCVFRIEND_kbv library.

I don’t have much experience with libraries, I felt that could be more explanations about the library, by comments in code for programers beginners start to make changes for yourself. When you depare with someone else code it’s hard to realize what the code does!
A tutorial about MCUFRIEND_kbv or Adafruit_TFTLCD_8bit_STM32 is welcome too!


mrburnette
Mon Oct 29, 2018 2:55 am
Have you read all pertinent posts:
https://www.google.com/search?&q=mcufri … 2duino.com

These Arduino shields are 5 Volt, so David’s post here is of note,

In the register listing in your post, I cannot find the string “9486” … I do not have a compatible display, so I have never run the utility – meaning I do not know what the output should be for “compatible” devices.

Ray


flyboy74
Mon Oct 29, 2018 3:27 am
Not sure how much help this is going to be but here is some of my experiences with these parallel screens.

I have been using these screens on STM32F407 but it will be similar with the STM32103. I first got them to work by writing my own bit bang library but then I got the hardware peripheral FSMC to drive the screens. Once setup the FSMC is easier.

The screens them selves run of 3v but they have circuits on the PCB so they can be run from 5v as they r designed for Ardunio. What I did was remove the 3.3v LDO and short out Vin and Vout pads where the LDO used to be this then just connect 3.3v to everything instead of 5v.

Here is the project I am working on today with a ili9341 in 16 bit parallel using the ADC to read the touch see https://www.youtube.com/watch?v=STBH8Vw … e=youtu.be

All my code just uses the macro’s in header supplied from ST “stm32f4xx.h”. I can make my code available if you want it but it is likely to need some mods to run a STM32F103

edit I have just looked closer at the blue pill specs and it doesn’t have a hardware FSCM peripheral so it has to be bit banged in software


flyboy74
Mon Oct 29, 2018 3:47 am
If you want to sit down and create your own bit-bang code to drive your screen it isn’t hard.

The screen will use a 8088 protocol. It works like this, u pull the CS pin low to talk to the screen(same as SPI) then you set the data pins to the data you want to sedn then you pulse the WR pin to get the screen to input the data you have set on the data lines. There is RS (sometimes called DC) pin that chooses whether the data is a command or data to be written to RAM.

To set the data 8 pins at once that are all on the same port and next to each other can be done by just writing the value to the ODR register for that port.

Here is the thread where I was working on a software bit bang viewtopic.php?f=3&t=3967&p=48025&hilit= … 325#p48025


david.prentice
Mon Oct 29, 2018 7:47 am
You have done everything correctly in your Original Post.

I will post the appropriate SPECIAL for you after I have taken my dog for his walk.

You don’t have to worry about coding anything yourself or level conversion. Just connect LCD_xxx signals to the Bluepill port pins and connect 3.3V, 5V, GND pins to the corresponding Bluepill power pins.

David.

Life is easier if you just use the “official hardware mod” Bluepill wiring e.g.
#define LCD_RST PB9
#define LCD_CS PB8
#define LCD_RS PB7
#define LCD_WR PB6
#define LCD_RD PB0


ericosowski
Tue Oct 30, 2018 3:04 am
[flyboy74 – Mon Oct 29, 2018 3:47 am] –
If you want to sit down and create your own bit-bang code to drive your screen it isn’t hard.

The screen will use a 8088 protocol. It works like this, u pull the CS pin low to talk to the screen(same as SPI) then you set the data pins to the data you want to sedn then you pulse the WR pin to get the screen to input the data you have set on the data lines. There is RS (sometimes called DC) pin that chooses whether the data is a command or data to be written to RAM.

To set the data 8 pins at once that are all on the same port and next to each other can be done by just writing the value to the ODR register for that port.

Here is the thread where I was working on a software bit bang viewtopic.php?f=3&t=3967&p=48025&hilit= … 325#p48025

Thank you flyboy, I intend to go deeper into this subject, I have a 16bit parallel lcl tft 3.5″ that I want to make it work, but not now! so your knowledge will be helpfull, but for now I’m needing a quickly solution for this 8bits parallel tft screen.
If you think I can learn something with your code Ill be glad with you share it!

Thank you for your reply and kindness to help!


ericosowski
Tue Oct 30, 2018 4:07 am
[david.prentice – Mon Oct 29, 2018 7:47 am] –
You have done everything correctly in your Original Post.

I will post the appropriate SPECIAL for you after I have taken my dog for his walk.

You don’t have to worry about coding anything yourself or level conversion. Just connect LCD_xxx signals to the Bluepill port pins and connect 3.3V, 5V, GND pins to the corresponding Bluepill power pins.

David.

Life is easier if you just use the “official hardware mod” Bluepill wiring e.g.
#define LCD_RST PB9
#define LCD_CS PB8
#define LCD_RS PB7
#define LCD_WR PB6
#define LCD_RD PB0


david.prentice
Tue Oct 30, 2018 6:55 am
Wire LCD_RD pin to PB0 on the BluePill
Edit the LCD_RD define for PB0 in LCD_ID_readreg sketch.

Run the sketch. You should see reg(0xd3) as xx 94 86 xx to confirm that your wires are all ok.

Then run any library examples. They should all work.

If you have altered anything, it is probably wise to start again.
i.e. leave IDE. Delete library directory. Start IDE. Re-install via the Library Manager.

David.

If you really want to use PB5 (it stops you using the microSD) edit the shield.h file
This means deleting the two slashes on the PB5 line and inserting two slashes on the PB0 line.


flyboy74
Tue Oct 30, 2018 8:07 am
[ericosowski – Tue Oct 30, 2018 3:04 am] –

[flyboy74 – Mon Oct 29, 2018 3:47 am] –
If you want to sit down and create your own bit-bang code to drive your screen it isn’t hard.

The screen will use a 8088 protocol. It works like this, u pull the CS pin low to talk to the screen(same as SPI) then you set the data pins to the data you want to sedn then you pulse the WR pin to get the screen to input the data you have set on the data lines. There is RS (sometimes called DC) pin that chooses whether the data is a command or data to be written to RAM.

To set the data 8 pins at once that are all on the same port and next to each other can be done by just writing the value to the ODR register for that port.

Here is the thread where I was working on a software bit bang viewtopic.php?f=3&t=3967&p=48025&hilit= … 325#p48025

Thank you flyboy, I intend to go deeper into this subject, I have a 16bit parallel lcl tft 3.5″ that I want to make it work, but not now! so your knowledge will be helpfull, but for now I’m needing a quickly solution for this 8bits parallel tft screen.
If you think I can learn something with your code Ill be glad with you share it!

Thank you for your reply and kindness to help!

Ok for your interest I have put the main functions up on github of the project that I posted running on a STM32F407VET board, it uses the FMSC HW peripheral to write to the LCD so not a bit bang as you will need on the bluepill see https://github.com/OutOfTheBots/ili9341_16bit_touch

here is some code from when I used bit bang on a hx8357b screen in 16bit parallel. Something similar to this is what you will need to write for the blue pill. All this code does is setup the screen and continuously write redish coloured pixels to the screen and see the discussion here viewtopic.php?f=3&t=3841&p=47071&hilit=hx8357#p47071
#include "stm32f4xx.h"

#define RS GPIO_ODR_ODR_0
#define WR GPIO_ODR_ODR_1
#define CS GPIO_ODR_ODR_2
#define RST GPIO_ODR_ODR_3

//used for count down in Delay
__IO uint32_t TimmingDelay;

void SysTick_Handler(void)
{
if(TimmingDelay !=0)
{
TimmingDelay --;
}
}

void Delay(__IO uint32_t time)
{
TimmingDelay = time;
while(TimmingDelay !=0);
}

void Pin_setup(void){
//enable port D and E
RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN | RCC_AHB1ENR_GPIOEEN;

//Port E is used for parallel data pins
//set a port E pins to output.
GPIOE->MODER = 0x55555555;
//set all port E pins to push pull
GPIOE->OTYPER = 0;
//set all port E pins to 100MHz speed
GPIOE->OSPEEDR =0xFFFFFFFF;

//Port D is used for RS, WR, CS, RST
//set needed pins as ouput
GPIOD->MODER |= GPIO_MODER_MODER0_0 | GPIO_MODER_MODER1_0 | GPIO_MODER_MODER2_0 | GPIO_MODER_MODER3_0;
//set needed pin to push pull
GPIOD->OTYPER = 0;
//set needed pins to 100MHZ;
GPIOD->OSPEEDR |= 0x000000FF;

GPIOD->ODR |= RS | WR | CS | RST;
}

void TFT_write_cmd(uint16_t command){
GPIOD->ODR &= ~RS;
GPIOD->ODR &= ~CS;
GPIOD->ODR &= ~WR;
GPIOE->ODR = command;
GPIOD->ODR |= WR;
GPIOD->ODR |= CS;
GPIOD->ODR |= RS;
}

void TFT_write_data(uint16_t data){
GPIOD->ODR &= ~CS;
GPIOD->ODR &= ~WR;
GPIOE->ODR = data;
GPIOD->ODR |= WR;
GPIOD->ODR |= CS;
}

void LCD_setup (void){
//hardware reset
GPIOD->ODR &= ~RST;
Delay(120);
GPIOD->ODR |= RST;
Delay(120);
//software reset
TFT_write_cmd(0x01);
Delay(120);
//sleep out
TFT_write_cmd(0x11);
Delay(120);
//Normal Display Mode On)
TFT_write_cmd(0x13);
//Display On
TFT_write_cmd(0x29);
//CASET (Column Address Set)
TFT_write_cmd(0x2A);
TFT_write_data (0000);
TFT_write_data (320);
//PASET (Page Address Set)
TFT_write_cmd(0x2B);
TFT_write_data (0000);
TFT_write_data (480);
//Exit_idle_mode
TFT_write_cmd(0x38);
//Set_pixel_format RGR565 16 bit
TFT_write_cmd(0x3A);
TFT_write_data(0b01010101);
//RAMWR (Memory Write)
TFT_write_cmd(0x2C);
}

void main(void){
SysTick_Config(SystemCoreClock/1000);
Pin_setup();
LCD_setup();

// Infinite loop
while (1)
{
//write some redish data to the screen
TFT_write_data(0xff00);
}
}


ericosowski
Tue Oct 30, 2018 4:27 pm
Hi David,
I assume that the right library is from the link below:
https://github.com/prenticedavid/MCUFRIEND_kbv
I changed the PIN LCD_RD for PB5 port, but I tried with PB0 too and nothing happened.
This ID 0xD3 was returned during one of my many tries to turn it on! And I saw that this ID make reference to ILI9486 in libray’s code, but even than it just shows white screen, so I presume that in one moment I wired it right, I’ll try again!
I’ll reinstall the library via Library Manager and see what happens.
The data pins is default pins PA0~PA7?
Does the pins below must be declared in the sketch header?

#define LCD_RST PB9
#define LCD_CS PB8
#define LCD_RS PB7
#define LCD_WR PB6
#define LCD_RD PB0


david.prentice
Tue Oct 30, 2018 6:10 pm
The readreg sketch does not use any libraries at all. Only the built-in digitalWrite() and pinMode().

Your Original Post showed readreg working for PB5. Change the wiring to PB0 and the define to PB0. The readreg sketch should give you the same output as in the OP.

It is wise to use the Library Manager to install libraries whenever possible.

Punters often try to put libraries into System folders or random locations. I suggest that you should remove wrongly installed libraries if there is an “official” third party library that is supported by the Manager e.g. Adafruit_GFX, MCUFRIEND_kbv, …
Then restart the IDE. Install with the Library Manager.

If you ever have a problem, copy-paste the last few lines from the verbose compilation e.g. memory and library use.

David.


ericosowski
Wed Oct 31, 2018 11:22 am
Hi David,
Good news, I did all the things you said and the TFT started to work, like magic! :D
You are the best!
Thank you very much!

david.prentice
Wed Oct 31, 2018 1:29 pm
Well done.

The secret is generally to leave the PC and sit down with a nice cup of tea.

Then do one step at a time. Make notes with pencil and paper as you go.

David.


Leave a Reply

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