Author Topic: STM32F407 & ILI9341 FSMC  (Read 11831 times)

0 Members and 1 Guest are viewing this topic.

Offline Quarlo KlobrigneyTopic starter

  • Frequent Contributor
  • **
  • Posts: 968
  • Country: pt
  • This Space For Rent
STM32F407 & ILI9341 FSMC
« on: December 27, 2021, 05:44:35 am »
I've been at this for a long time now. All the examples of making the STM3F407VET6 board http://www.lcdwiki.com/STM32F407VxT6_Board talk to the ILI9341 TFT in 16 bit FSMC mode, are crap.

I managed to download several YouTube, Chinese, Japanese "working" examples, but none work correctly. The examples range from STM Cube with either Keil or IAR compilers (2 couldn't be compiled for size limits) or TouchGFX (compile size limit).

From the link, http://www.lcdwiki.com/res/STM3203/STM32F407VxT6%E6%9C%80%E5%B0%8F%E7%B3%BB%E7%BB%9F%E6%9D%BF%E7%A4%BA%E4%BE%8B%E7%A8%8B%E5%BA%8F.zip we have an example, buried in Chinese character folder names which show as gibberish on a PC.

http://www.lcdwiki.com/3.2inch_16BIT_Module_ILI9341_SKU:MRB3205 then http://www.lcdwiki.com/res/Program/Parallel_Port/3.2inch/16BIT_ILI9341_MRB3205_V1.0/3.2inch_16BIT_Module_ILI9341_MRB3205_V1.0.zip reveals the second failure example.

If one drills down and renames the folders up the tree so that Keil can understand where it is, we get to a folder STM32F407VET6_LCD\Demo_3.2inch_MRB3205_240x320_ILI9341_STM32F407VET6_FSMC, the pin assigns on the 2 LED's are wrong. The board LED's are on PA6 & PA7. The software had them on 0 & 1.

When I first programmed the board, the LCD goes through various flashings in a timed manor and stops. After changing the LED assignments, the display does the same as before, but now when it finishes, it does so with an LED blinking indicating the demo is done.

I'm sure that the LCD pin assigns are wrong in the software as well, but they are buried in the HAL so deep I wouldn't know where to find them to fix them.

Without the Cube project, I would have no idea where the pins are mapped.

By the way, the LCD and Demo Board are pin for pin compatible. Having checked a dozen or more times, I can attest to that.

In closing, can someone here look at the code folder mentioned above and provide an idea of where the assignments are?
Or, is there a suitable demo for the the pair elsewhere?
Lot's of videos with demos drawing away happily that don't work in practice.
« Last Edit: December 30, 2021, 01:10:38 pm by Quarlo Klobrigney »
Voltage does not flow, nor does voltage go.
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: zm
Re: STM3F407 & ILI9341 FSMC
« Reply #1 on: December 27, 2021, 09:55:22 am »
I Have not looked at your link yet but, i will but before i do I can add something to this that I have had issues with so my pain might not be yours.
1. I have found most examples are broken when used in later/modern versions of compilers for one reason or another (stm32 code pre 8 works but after 9 you will have cube lib issues ) and keil is just to variable between mcu's and longer learning curve for some like me.
2. FSMC on 407_vet requires all the correct steps are taken , clocks , gpio config, fsmc (this include which pins are ws/wr/rd/cs)
3. lots of FSMC code out there but non fully explain the CS pins and memory read/write in usage or config(the will example their usage but not say another one to give context)
4. if you want to us STM then i suggest vscode platformio , it supports cubemx, arduino, cmsis and more, the reason i use it often is i can import sample code from many source libs type (cubemx,cmsis) into a fresh project easily and also use library's easily (theres some trick to that but i can explain and demonstrate   )
5. between different HAL libs (cubemx, arduino, cmsis) the hardware is often reference in totally ways and often setup and treated as different groups , where cmsis will setup a peripheral (lets say FSMC ) as just the FSMC hardware (no gpio settings, no clock setup yet)  the ST CUBEMX will setup clocks, gpio, irq's, dma and then FSMC in one call (HAL_FSMC_Init();)
6. when starting out with stm32 it is worth having both platformio and stmcube mx /stm cube programmer installed, the reason is you can use the GUI of stm32 cubemx to configure your MCU/CPU and export that project, then with a few simple changes to a platformio.ini file you can have a instant populated project with peripherals configured , the cubemx IDE also has PDF's and pinouts to the chips so i will often use it just for that and do the code in platformio , i use it because its got plugins that allow me to follow the code easier to the HAL_LL or hall low level and then i can create a bare metal version from there.


Now onto help to configure the FSMC, as mentioned you need GPIO, clocks, FSMC itself ,dma and irq's with the latter two not fully required for initial function (and give no benefit in the start)

First lets cover configuring the actual devices we are going to use , this hardware is the default pins that most fsmc project uses the default  except the "CS , read/write/command" 
that would be
Code: [Select]
// TFT connector uses FSMC pins
// D0   D1   D2  D3  D4  D5  D6  D7   D8   D9   D10  D11  D12  D13 D14 D15
// PD14 PD15 PD0 PD1 PE7 PE8 PE9 PE10 PE11 PE12 PE13 PE14 PE15 PD8 PD9 PD10
with our bank addressing (where you read/write to lcd)
at
Code: [Select]
#define FMC_REGION ((uint32_t)0x60000000) // Bank1 FMC NOR/PSRAM

#define CommandAccess FMC_REGION //write to this address as a command
//#define DataAccess (FMC_REGION + 0x20000) // FSMC_A16
#define DataAccess (FMC_REGION + 0x40000) // FSMC_A17 //write to this address to data

now you will note we have the above #define for the DATA portion of the LCD/FSMC , now just because we define it there does not mean we have configured the hardware fully,

in the following list we define the setup of the FSMC, which is NE1(_CS), FSMC_A17 (_RS), FSMC_NWE(_wr) , FSMC_NOE (_rd)  pins,
in my example they are :-
Code: [Select]
** note code, just a list for remembering **
  _cs   = PD7;  // FSMC_NE1 chip select when low
  _rs   = PD12; // FSMC_A17 //Use PD11 for FSMC_A16 , rs is also known as REGISTER_SELECT and switches between command mode/data mode , when low mode is command mode
  _rst  = 0;    // not available, driven from NRST
  _wr   = PD5;  // FSMC_NWE
  _rd   = PD4;  // FSMC_NOE


Actual values used in code
Code: [Select]
#define PD_AFR0_MASK         0xF0FF00FF
#define PD_AFR0_FSMC         0xC0CC0CCC
#define PD_AFR1_MASK 0xFFF00FFF
#define PD_AFR1_FSMC 0xCC0C0CCC
//                    config for FSMC_A17  as command/data pin
#define PD_MODE_MASK 0xFC3FCF0F // all FMSC MODE bits
#define PD_MODE_FSMC 0xA22A8A2A // FMSC MODE values 10 alternate function
//#define PD_OSPD_FSMC 0x54154505 // FMSC OSPEED values 01 10MHz
#define PD_OSPD_FSMC 0xf33fcf3f // FMSC OSPEED values 01 10MHz
//                    |       |        |
#define PE_AFR0_MASK         0xF0000000
#define PE_AFR0_FSMC         0xC0000000
#define PE_AFR1_MASK 0xFFFFFFFF
#define PE_AFR1_FSMC 0xCCCCCCCC
//                    |       |        |
#define PE_MODE_MASK 0xFFFFC000 // all FMSC MODE bits
#define PE_MODE_FSMC 0xAAAA8000 // FMSC MODE values 10 alternate function
#define PE_OSPD_FSMC 0x55554000 // FMSC OSPEED values 01 10MHz

#define ADDSET 10 // (ADDSET+1)*6ns = CS to RW
#define DATAST 15 // (DATAST+1)*6ns = RW length

and usage in setup function.

Code: [Select]

void GxIO_STM32F407VxT6_FSMC::init()
{
  RCC->AHB1ENR |= 0x00000078; // enable GPIOD, GPIOE, GPIOF and GPIOG interface clock
  volatile uint32_t t = RCC->AHB1ENR; // delay

  GPIOD->AFR[0]  = ( GPIOD->AFR[0] & ~PD_AFR0_MASK) | PD_AFR0_FSMC;
  GPIOD->AFR[1]  = ( GPIOD->AFR[1] & ~PD_AFR1_MASK) | PD_AFR1_FSMC;
  GPIOD->MODER   = ( GPIOD->MODER & ~PD_MODE_MASK) | PD_MODE_FSMC;
  GPIOD->OSPEEDR = ( GPIOD->OSPEEDR & ~PD_MODE_MASK) | PD_OSPD_FSMC;
  GPIOD->OTYPER &= ~PD_MODE_MASK;
  GPIOD->PUPDR  &= ~PD_MODE_MASK;

  GPIOE->AFR[0]  = (GPIOE->AFR[0] & ~PE_AFR0_MASK) | PE_AFR0_FSMC;
  GPIOE->AFR[1]  = (GPIOE->AFR[1] & ~PE_AFR1_MASK) | PE_AFR1_FSMC;
  GPIOE->MODER   = (GPIOE->MODER & ~PE_MODE_MASK) | PE_MODE_FSMC;
  GPIOE->OSPEEDR = (GPIOE->OSPEEDR & ~PE_MODE_MASK) | PE_OSPD_FSMC;
  GPIOE->OTYPER &= ~PE_MODE_MASK;
  GPIOE->PUPDR  &= ~PE_MODE_MASK;

  RCC->AHB3ENR |= 0x00000001;
  t = RCC->AHB1ENR; // delay
  (void)(t);

  FSMC_Bank1->BTCR[0] = 0x00001091;
  FSMC_Bank1->BTCR[1] = (DATAST << 8) | ADDSET;

 
}


as to what MODER, OSPEEDR etc mean you can find that in the 407_vet manual available via cubemx or stm32 web site ,  but the short of them are they are the registers for each port (GPIOD,GPIOE etc) and the binary bits configure their operation. a example is
for FSMC_A17 (the _rs trigger, PD12)
Code: [Select]
#define PD_MODE_MASK 0xFC3FCF0F // all FMSC MODE bits
#define PD_MODE_FSMC 0xA22A8A2A // FMSC MODE values 10 alternate function
#define PD_OSPD_FSMC 0xf33fcf3f // FMSC OSPEED values 01 10MHz

but if you need to use FSMC_A16 pin (PD11) then it's
Code: [Select]
#define PD_MODE_MASK 0xF0FFCF0F // all FMSC MODE bits
#define PD_MODE_FSMC 0xA0AA8A0A // FMSC MODE values 10 alternate function
#define PD_OSPD_FSMC 0x50554505 // FMSC OSPEED values 01 10MHz

it's not often obvious what the value are ment to be in the manual (it's also not just in one manual but spread across a few ) how ever the cubeMX IDE can help you get the config right and then you take those values and paste into your example,

I do have a few examples on my github for using platformio and the above config for my MKS_TFT35_V1 lcd board
an example would be this which uses the stm32 cubemx (you can load the project into platformio or cubemx)
https://github.com/darkspr1te/mkstft35_V1_open_bootloader
or his one which use bare metal more or less
https://github.com/darkspr1te/mkstft35_bl_alt



Well, I hope this helps, i'll post more after reading the links you have posted

regards

darkspr1te
« Last Edit: December 27, 2021, 10:45:03 am by darkspr1te »
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: zm
Re: STM3F407 & ILI9341 FSMC
« Reply #2 on: December 27, 2021, 10:33:21 am »
I took a look at the pinouts for the board according to the picture, try the following,

in platformio (it handles a lot of the downloading for you )
create a blank arduino project for
genericSTM32F407VET6

in you platformio.ini paste the following (overwrite the all in the info )
Code: [Select]
; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:black_f407ve]
platform = ststm32
board = genericSTM32F407VET6
framework = arduino


build_flags =
-DVECT_TAB_OFFSET=0
-DHSE_VALUE=8000000
-w
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D USBCON
-DUSBD_VID=0
-DUSBD_PID=0
-DUSB_MANUFACTURER="Unknown"
-DUSB_PRODUCT="\"generic_407\""
-DUSE_HAL_DRIVER



lib_deps =
 ;IRremoteESP8266=https://github.com/markszabo/IRremoteESP8266/archive/master.zip
 GXTFT=https://github.com/ZinggJM/GxTFT.git

in main.cpp
past the following
Code: [Select]

#include <GxTFT.h> // Hardware-specific library
#include <GxCTRL/GxCTRL_ILI9481/GxCTRL_ILI9481.h> // 240x320
#include <GxIO/STM32MICRO/GxIO_STM32F407VxT6_FSMC/GxIO_STM32F407VxT6_FSMC.h> // FSMC mode

//#include <GxIO/STM32MICRO/GxIO_STM32F407VxT6_P16/GxIO_STM32F407VxT6_P16.h> // file can be altered to do bit bash

#define TFT_Class GxTFT
GxIO_Class io; // #define GxIO_Class is in the selected header file

GxCTRL_Class controller(io); // #define GxCTRL_Class is in the selected header file
// select one or adapt
TFT_Class tft(io, controller, 320, 480); // landscape 240x320
#include "GxReadRegisters.h"




//defines


 int PIN_LIGHT = PIN_C5;//modify to



and replace void setup with :-
Code: [Select]

void setup() {
  // put your setup code here, to run once:
    //If you're using a Leonardo / Pro-micro this line can be left out.
    //while (!Serial) ;
   Serial.begin(115200);
    //If you notice some instability gradually increase this value with increments of 5.
    Serial.setTimeout(15);


 pinMode(PIN_LIGHT,OUTPUT);
 digitalWrite(PIN_LIGHT,HIGH);
//blink LCD_LED backlight 10 times to show booting
 for (int x=0;x<10;x++)
    {
      delay(100);
      digitalWrite(PIN_LIGHT,LOW);
      delay(100);
      digitalWrite(PIN_LIGHT,HIGH);
    }
 
  tft.init();
  tft.setRotation(1);
  tft.setCursor(0, 0);
  tft.setTextColor(WHITE);
  tft.setTextSize((tft.width() > 320) ? 2 : 1);
  tft.fillScreen(GREENYELLOW);
  tft.print("Starting");
  tft.println();
  delay(50);
  tft.fillScreen(BLUE);

}



the key parts to configure the FSMC and backlight etc can be found in .pio\libdeps\generic_f407ve\GXTFT\src\GxIO\STM32MICRO\GxIO_STM32F407VxT6_FSMC\GxIO_STM32F407VxT6_FSMC.cpp

look for
Code: [Select]
#define PD_AFR0_MASK         0xF0FF00FF
#define PD_AFR0_FSMC         0xC0CC00CC
#define PD_AFR1_MASK 0xFF00FFFF
#define PD_AFR1_FSMC 0xCC00CCCC

#define PD_MODE_MASK 0xF0FFCF0F // all FMSC MODE bits
#define PD_MODE_FSMC 0xA0AA8A0A // FMSC MODE values 10 alternate function
#define PD_OSPD_FSMC 0x50554505 // FMSC OSPEED values 01 10MHz
//                    |       |        |
#define PE_AFR0_MASK         0xF0000000
#define PE_AFR0_FSMC         0xC0000000
#define PE_AFR1_MASK 0xFFFFFFFF
#define PE_AFR1_FSMC 0xCCCCCCCC
//                    |       |        |
#define PE_MODE_MASK 0xFFFFC000 // all FMSC MODE bits
#define PE_MODE_FSMC 0xAAAA8000 // FMSC MODE values 10 alternate function
#define PE_OSPD_FSMC 0x55554000 // FMSC OSPEED values 01 10MHz

#define ADDSET 10 // (ADDSET+1)*6ns = CS to RW
#define DATAST 15 // (DATAST+1)*6ns = RW length

#define FMC_REGION ((uint32_t)0x60000000) // Bank1 FMC NOR/PSRAM

#define CommandAccess FMC_REGION
#define DataAccess (FMC_REGION + 0x20000) // FSMC_A16
« Last Edit: December 27, 2021, 10:35:55 am by darkspr1te »
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: zm
Re: STM3F407 & ILI9341 FSMC
« Reply #3 on: December 27, 2021, 10:48:39 am »
And here's a good link that explains the registers better than I

http://microelk.azurewebsites.net/STM32_CZ_mini/STM32_CZ_mini

and a example of setting up CubeMX for a device ,
http://www.emcu.it/STM32clk/STM32clk.html

« Last Edit: December 27, 2021, 10:50:24 am by darkspr1te »
 

Offline Quarlo KlobrigneyTopic starter

  • Frequent Contributor
  • **
  • Posts: 968
  • Country: pt
  • This Space For Rent
Re: STM32F407 & ILI9341 FSMC
« Reply #4 on: December 27, 2021, 06:30:55 pm »
You assume I know how to do all of that.
I'm still in the learning phase.

It turns out that the examples are really for the STM32F407VGT6 and not the STM32F407VET6.
The folders are named STM32F407VET6 but opening the files they are marked as "for STM32F407VGT6" in the actual file header descriptions. :-DD Slightly different animal.

I have zipped the 3.2" TFT folder up and it went from 21.7Mb to 853Kb.

I can attach it here if you or anyone else is interested.

I lieu of this can someone provide a working example please.
« Last Edit: December 30, 2021, 01:11:04 pm by Quarlo Klobrigney »
Voltage does not flow, nor does voltage go.
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: zm
Re: STM3F407 & ILI9341 FSMC
« Reply #5 on: December 28, 2021, 10:17:10 am »
OK, first lets take a step back, as my mum used to say , let walk before you run,


step one is get the right IDE(s) ,
goto
https://code.visualstudio.com/download
and download and install vscode
then goto
https://platformio.org/platformio-ide
and click install for vscode

once you have done the two above items we then should have a vscode/platformio icon on the desktop.

load up vscode and click the ant looking icon in the bottom left , the quick link section should list "Update all" , click this and allow it to pull the current supported devices list.
once update has completed (quick at first but as you add more cpu type it will get slower) then close and reopen vscode ,
on the main screen (which should display large orange ant) click new project, input a project name and in mcu/devices section and type 32f407ve, then select Black STM32F407VE  , platform Arduino
(I have the same 407 board as you but it's a clone and does not work with the Black STM32407ve option at all, it does work with generic407vet as board type)


Next make sure you have the schematic handy ,
http://www.lcdwiki.com/res/STM3203/STM32F407VxT6_Board_Schematic.pdf

in the setup function put this
Code: [Select]

 int PIN_LIGHT = PIN_A1; //we define out LED0 here
//  LED0/LED1 HIGH/LOW value inverted due to MCU providing drain/GND for led and not source/3.3v

void setup() {
  // put your setup code here, to run once:
    pinMode(PIN_LIGHT,OUTPUT);
  digitalWrite(PIN_LIGHT,LOW); //LED comes via 3.3v
  for (int count=0;count<100;count++)
{
 delay(100);
 digitalWrite(PIN_LIGHT,HIGH); //turn off led0
 delay(100);
 digitalWrite(PIN_LIGHT,LOW); //turn on led0
}
}

then upload to your device, we should confirm it's running with a flashing LED0 (top most led next to winbond spi flash)
if we dont have a led flashing then it's either the wrong pin (schematics wrong) or wrong board type and we need to switch to generic board and set some specific defines to narrow it down to our board, we can discuss this further if this is the case.

we can spice up the code by adding LED1 which in STM32 terms is PC5 (Port C pin 5) and arduino is PIN_PC5 (in low level is GPIOC->BSRR = (0x1 << (5 + 16)); // PC5 low  )

so we would have 3 things to activate out second led,
the define :- int PIN_LIGHT1 = PIN_PC5;
the mode switching of the pin to configure the pin for you exact use   :- pinMode(PIN_LIGHT1,OUTPUT); 
the operation of the pin :- digitalWrite(PIN_LIGHT1,HIGH);

once you can hello world any pin of your choice (adding a led+resistor to the pin to show output of course) then we can do debug easier ,
let us know how you get along,

darkspr1te
« Last Edit: December 28, 2021, 10:41:33 am by darkspr1te »
 

Offline Quarlo KlobrigneyTopic starter

  • Frequent Contributor
  • **
  • Posts: 968
  • Country: pt
  • This Space For Rent
Re: STM32F407 & ILI9341 FSMC
« Reply #6 on: December 28, 2021, 08:54:37 pm »
Hours later, I'm still waiting, "Project Wizard, Please Wait".
Now I know why I removed Platform IO in the first place.

I know you are trying to help, but this excruciatingly slow.
There is a long road to travel before this IDE shows any picture on the LCD let alone blink an LED or 2.

Speaking of, my LEDs are on PA6 & PA7. My board is the VET6 not the 1M VGT6.
Are you sure you have the same board?

Signed still waiting........
« Last Edit: December 30, 2021, 01:11:21 pm by Quarlo Klobrigney »
Voltage does not flow, nor does voltage go.
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: zm
Re: STM3F407 & ILI9341 FSMC
« Reply #7 on: December 29, 2021, 06:10:42 am »
Hours later, I'm still waiting, "Project Wizard, Please Wait".
Now I know why I removed Platform IO in the first place.

I know you are trying to help, but this excruciatingly slow.
There is a long road to travel before this IDE shows any picture on the LCD let alone blink an LED or 2.

Speaking of, my LEDs are on PA6 & PA7. My board is the VET6 not the 1M VGT6.
Are you sure you have the same board?

Signed still waiting........
Odd, I have no issues with vscode and platformio at all. as for the board, yes i do (vet6) but not on my desk right now so I was going off the link you provided for  the schematic.
in the past i have done a few remote board bring up so this should be no different but point is, if we can blink a led we can FSMC the heck out of it too.


darkspr1te
 
 

Offline Quarlo KlobrigneyTopic starter

  • Frequent Contributor
  • **
  • Posts: 968
  • Country: pt
  • This Space For Rent
Re: STM32F407 & ILI9341 FSMC
« Reply #8 on: December 29, 2021, 06:28:22 am »
I got up to water the garden. If you're still there....
From the page linked, it is showing the VGT assignments. Please use the provided schematic.
As far as PIO I gave up, tomorrow today is another day. I got lost at compiling as there was no easy way to press a button and that was all I could take.
« Last Edit: December 30, 2021, 01:11:35 pm by Quarlo Klobrigney »
Voltage does not flow, nor does voltage go.
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: zm
Re: STM3F407 & ILI9341 FSMC
« Reply #9 on: December 29, 2021, 06:55:25 am »
OOH Kaaay, right off the bat i can see this new schematic is using A18 and not A16/A17 for the lcd trigger, thats why most demos dont work , 

as for compiling in vscode/platform io,
ctrl+alt+u = upload,
ctrl+alt+b = build
ctrl+alt+c = clean build (no all versions )
anyway, before i go on , which IDE/dev environment are you using so i can load up the same and confirm the same. if it's keil then will have to wait while i sign up and re-download it which wont be today (i am in the darkest Africa where internet speeds are from last centaury)
 

Offline Quarlo KlobrigneyTopic starter

  • Frequent Contributor
  • **
  • Posts: 968
  • Country: pt
  • This Space For Rent
Re: STM32F407 & ILI9341 FSMC
« Reply #10 on: December 29, 2021, 11:10:56 pm »
Well, those keys aren't working. See build error 1.
Then it's also complaining of a path error for the includes. See build error 2.

As far as my favorite tool (although bloated) is CubeIDE-MX whatever one gets it done, as it has a GUI and no guesswork, with Atollic True Studio 9.3 for STM32 as it also is more user friendly.
« Last Edit: December 30, 2021, 01:11:55 pm by Quarlo Klobrigney »
Voltage does not flow, nor does voltage go.
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: zm
Re: STM3F407 & ILI9341 FSMC
« Reply #11 on: December 30, 2021, 08:37:21 am »
Ok, it looks like you are trying to build within one of the other demo folders and that will cause issues with the compiler, hence it cannot find arduino.h and build keys dont work.

let me create a project and upload and test if it build under your version of stmcube
from there we can add lcd features (i've done this a LOT and have some good tricks)


darkspr1te
 

Offline Quarlo KlobrigneyTopic starter

  • Frequent Contributor
  • **
  • Posts: 968
  • Country: pt
  • This Space For Rent
Re: STM32F407 & ILI9341 FSMC
« Reply #12 on: December 30, 2021, 08:49:28 am »
I don't think so, but what do I know. Whatever you can do to help, I appreciate it.

Voltage does not flow, nor does voltage go.
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: zm
Re: STM3F407 & ILI9341 FSMC
« Reply #13 on: December 30, 2021, 10:28:07 am »
Ok, first off, download this .ioc file which is a blank project for your board with only UART,LEDs,backlight and FSMC on A18 ,import it and create a new project with it.
file the while loop and adjust as below,
compile and upload, tell me results on the various LEDS.



Code: [Select]
while (1)
  {
    /* USER CODE END WHILE */
  HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,GPIO_PIN_SET);
  HAL_Delay(100);
  HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,GPIO_PIN_RESET);
  HAL_Delay(100);
  HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_RESET);
  HAL_Delay(100);
  HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_SET);
  HAL_Delay(100);
   HAL_GPIO_WritePin(GPIOA,GPIO_PIN_6,GPIO_PIN_SET);
  HAL_Delay(100);
  HAL_GPIO_WritePin(GPIOA,GPIO_PIN_6,GPIO_PIN_RESET);
  HAL_Delay(100);
    /* USER CODE BEGIN 3 */
  }
/
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6183
  • Country: es
Re: STM3F407 & ILI9341 FSMC
« Reply #14 on: December 30, 2021, 11:00:41 am »
Code wrongly placed! Anything after "USER CODE END" will get wiped on MX code generation  ;)
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: zm
Re: STM3F407 & ILI9341 FSMC
« Reply #15 on: December 30, 2021, 11:15:52 am »
Code wrongly placed! Anything after "USER CODE END" will get wiped on MX code generation  ;)
Ah ok, I dont use cubeide myself so didnt know about that
my stlink is a clone so does not work with cubeide (fine with cubeprg though)
but once we got blink we can move on to lcd code generation and build the bones of the lcd interaction


darkspr1te
 

Offline Quarlo KlobrigneyTopic starter

  • Frequent Contributor
  • **
  • Posts: 968
  • Country: pt
  • This Space For Rent
Re: STM32F407 & ILI9341 FSMC
« Reply #16 on: December 30, 2021, 12:23:25 pm »
TrueStudio has become useless as it does not accept the paths even after being defined.
After 3+ hours of this I an done with it.

I did however compile it for IAR and changed the delay from 100 to 1000 and it functions properly on the board as expected. My only worry is that further LCD code will exceed the size limit for the free version.
Code: [Select]
/* USER CODE BEGIN WHILE */
   while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
      HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,GPIO_PIN_SET);
      HAL_Delay(1000);
      HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,GPIO_PIN_RESET);
      HAL_Delay(1000);
      HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_RESET);
      HAL_Delay(1000);
      HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_SET);
      HAL_Delay(1000);
      HAL_GPIO_WritePin(GPIOA,GPIO_PIN_6,GPIO_PIN_SET);
      HAL_Delay(1000);
      HAL_GPIO_WritePin(GPIOA,GPIO_PIN_6,GPIO_PIN_RESET);
      HAL_Delay(1000);
  }
  /* USER CODE END 3 */
}
« Last Edit: December 30, 2021, 12:31:47 pm by Quarlo Klobrigney »
Voltage does not flow, nor does voltage go.
 

Offline Quarlo KlobrigneyTopic starter

  • Frequent Contributor
  • **
  • Posts: 968
  • Country: pt
  • This Space For Rent
Re: STM32F407 & ILI9341 FSMC
« Reply #17 on: December 30, 2021, 12:37:28 pm »
I did change you clock paths to reflect the following:
Voltage does not flow, nor does voltage go.
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: zm
Re: STM32F407 & ILI9341 FSMC
« Reply #18 on: December 30, 2021, 12:46:08 pm »
I did change you clock paths to reflect the following: (Attachment Link)
Yes, it's my default file i use, but if they are incorrect for you feel free to adjust the profile, the point is we need a led hello world to confirm things.
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: zm
Re: STM32F407 & ILI9341 FSMC
« Reply #19 on: December 30, 2021, 12:52:57 pm »
TrueStudio has become useless as it does not accept the paths even after being defined.
After 3+ hours of this I an done with it.

I did however compile it for IAR and changed the delay from 100 to 1000 and it functions properly on the board as expected. My only worry is that further LCD code will exceed the size limit for the free version.
Code: [Select]
/* USER CODE BEGIN WHILE */
   while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
      HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,GPIO_PIN_SET);
      HAL_Delay(1000);
      HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,GPIO_PIN_RESET);
      HAL_Delay(1000);
      HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_RESET);
      HAL_Delay(1000);
      HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_SET);
      HAL_Delay(1000);
      HAL_GPIO_WritePin(GPIOA,GPIO_PIN_6,GPIO_PIN_SET);
      HAL_Delay(1000);
      HAL_GPIO_WritePin(GPIOA,GPIO_PIN_6,GPIO_PIN_RESET);
      HAL_Delay(1000);
  }
  /* USER CODE END 3 */
}
I thought you were using stmcube ide ? i downloaded the current one and created that file with it, i think part of your issue is you are jumping between IDE's , build chains in the hope of having a working lcd but in fact you need to learn about the board you are using and how it works and to do that you need to stay within one build environment, until you are comfortable building under different make systems.

with the above project file and the changes i mentioned under stmcube ide i (after patching the slink device) can now upload the same file and have led0/1 alternate , while my pins for led are different we both have 8mhz xtal , thats the base figure needed to basic boot so long as the board is fine, the chip number is correct.


darkspr1te

 

Offline Quarlo KlobrigneyTopic starter

  • Frequent Contributor
  • **
  • Posts: 968
  • Country: pt
  • This Space For Rent
Re: STM32F407 & ILI9341 FSMC
« Reply #20 on: December 30, 2021, 01:06:57 pm »
I think you misunderstand me. The CubeMX is still doing the configurations but the only compilers that work are either Keil µVision 5.36 or IAR 9.20.2.43979.
All other compilers generate excessive errors. >:(
« Last Edit: December 30, 2021, 01:10:22 pm by Quarlo Klobrigney »
Voltage does not flow, nor does voltage go.
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: zm
Re: STM32F407 & ILI9341 FSMC
« Reply #21 on: December 30, 2021, 02:38:29 pm »
CubeMX, CubeIDE and CubePRg a 3 different programs, so from what you have said i got this,

You are Using CubeMX to generate the files and folders using either keil or IAR as IDE as compilers,
ok i will refer to my prior statement that both those programs dont take into account version changes from stmcube output, i might not have made the coloration clear though.

first this is this is correct, then Dont do it!!, it wont make further development any easier unless you trying old code and even then often you can boil it down to the calls being expanded or contracted.
I see from you prior postings you know you electronics but software not so, correctly configured .ini file allows you to compile *Most code ,
 

So let be a equal footing software wise and fix your platformio issues (once fixed allow any MCU with minor changes)
tip one, if you tried platformio in a folder of data and change some settings you have to delete the .pio folder and even .debug or even .vscode folder to start build anew
tip two, you cant open a non platformio folder with a basic platformio.ini file ,
tip three,you can bypass platformio ability to include all files buy using a few config in the ini, this allows you to compile cmis, stm32cube, version of the same files wil little changes yet they are in the same folder ( more on that later)

i do have a discord send me a private message for those details.


darkspr1te

 


« Last Edit: December 30, 2021, 06:02:59 pm by darkspr1te »
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6183
  • Country: es
Re: STM32F407 & ILI9341 FSMC
« Reply #22 on: December 30, 2021, 03:04:11 pm »
CubeMX is embedded in CubeIDE, you don't need CubeProg.
Just use CUbeIDE from the beginning. Create a new stm32 project, setup MX and you'll be ready to go.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Quarlo KlobrigneyTopic starter

  • Frequent Contributor
  • **
  • Posts: 968
  • Country: pt
  • This Space For Rent
Re: STM32F407 & ILI9341 FSMC
« Reply #23 on: December 30, 2021, 06:06:14 pm »
That's what I have been using (IDE).
It's been some years since I had any time to do STM programming.
Back in that day I was looking at projects so that I could understand how things worked.
In that time, MX was all that there was.
It's been difficult to get back to speed especially now that I'm older, but being retired gives me the opportunity to learn, although at a slower pace.
I don't use Platform IO and have no desire to do so again. I think it is bloated and an unnecessary resource hog. Just my experiences after trying it a while back.

After configuring the hardware for the LCD for about 12 or so times, each time enabling FSMC, clock sources, Timer 6, FATFS, IO pins and functions, I am down to 247 errors such as

Code: [Select]
void ili9341_DisplayOff(void)
{
  ILI9341_LCDMUTEX_PUSH();
  LCD_IO_WriteCmd8(ILI9341_SLPIN);    // Sleep
  ILI9341_LCDMUTEX_POP();
  LCD_IO_Bl_OnOff(0);
}
Voltage does not flow, nor does voltage go.
 

Offline Quarlo KlobrigneyTopic starter

  • Frequent Contributor
  • **
  • Posts: 968
  • Country: pt
  • This Space For Rent
Re: STM32F407 & ILI9341 FSMC
« Reply #24 on: December 30, 2021, 06:14:39 pm »
With the first opening brace in error red with no explanation as to why.
I think it is down to old libraries that have not moved forward while the tools have.
I already knew that the hardware works and I can do my own IO led blinking.
I just needed a working example of how to get the LCD to show anything other than flashing shades of white.
Examples are available from the 407 wiki page but they are for a different board but mislabeled by the Chinese coder(s) as functional examples. BTW, I have spent a few days translating their comments from the files to get a grip on what's going on, all to find out the examples are for a different board/LCD.

At this point if anyone has a solution I'm getting to the point of chucking it in a box and moving on with my life. I'm just that fed up and my sanity is worth more than a 3.2" LCD. :horse: :horse: :horse:


« Last Edit: December 30, 2021, 06:16:31 pm by Quarlo Klobrigney »
Voltage does not flow, nor does voltage go.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf