STM32F407 & ILI9341 FSMC - Page 1
Forum section: electronics / general

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: December 27, 2021, 05:44:35 am
content: I've been at this for a long time now. All the examples of making the STM3F407VET6 boardhttp://www.lcdwiki.com/STM32F407VxT6_Boardtalk 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.zipwe 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:MRB3205thenhttp://www.lcdwiki.com/res/Program/Parallel_Port/3.2inch/16BIT_ILI9341_MRB3205_V1.0/3.2inch_16BIT_Module_ILI9341_MRB3205_V1.0.zipreveals 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.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 27, 2021, 09:55:22 am
content: 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 beCode:// 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 PD10with our bank addressing (where you read/write to lcd)atCode:#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 datanow 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:** 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_NOEActual values used in codeCode:#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 lengthand usage in setup function.Code:void GxIO_STM32F407VxT6_FSMC::init(){RCC->AHB1ENR |= 0x00000078; // enable GPIOD, GPIOE, GPIOF and GPIOG interface clockvolatile uint32_t t = RCC->AHB1ENR; // delayGPIOD->AFR = ( GPIOD->AFR & ~PD_AFR0_MASK) | PD_AFR0_FSMC;GPIOD->AFR = ( GPIOD->AFR & ~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 = (GPIOE->AFR & ~PE_AFR0_MASK) | PE_AFR0_FSMC;GPIOE->AFR = (GPIOE->AFR & ~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 = 0x00001091;FSMC_Bank1->BTCR = (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 isfor FSMC_A17 (the _rs trigger, PD12)Code:#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 10MHzbut if you need to use FSMC_A16 pin (PD11) then it'sCode:#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 10MHzit'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 boardan 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_bootloaderor his one which use bare metal more or lesshttps://github.com/darkspr1te/mkstft35_bl_altWell, I hope this helps, i'll post more after reading the links you have postedregardsdarkspr1te

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 27, 2021, 10:33:21 am
content: 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 forgenericSTM32F407VET6in you platformio.ini paste the following (overwrite the all in the info )Code:; 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 = ststm32board = genericSTM32F407VET6framework = arduinobuild_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_DRIVERlib_deps =;IRremoteESP8266=https://github.com/markszabo/IRremoteESP8266/archive/master.zipGXTFT=https://github.com/ZinggJM/GxTFT.gitin main.cpppast the followingCode:#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 GxTFTGxIO_Class io; // #define GxIO_Class is in the selected header fileGxCTRL_Class controller(io); // #define GxCTRL_Class is in the selected header file// select one or adaptTFT_Class tft(io, controller, 320, 480); // landscape 240x320#include "GxReadRegisters.h"//definesint PIN_LIGHT = PIN_C5;//modify toand replace void setup with :-Code: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 bootingfor (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.cpplook forCode:#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

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 27, 2021, 10:48:39 am
content: And here's a good link that explains the registers better than Ihttp://microelk.azurewebsites.net/STM32_CZ_mini/STM32_CZ_miniand a example of setting up CubeMX for a device ,http://www.emcu.it/STM32clk/STM32clk.html

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: December 27, 2021, 06:30:55 pm
content: 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.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.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 28, 2021, 10:17:10 am
content: 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) ,gotohttps://code.visualstudio.com/downloadand download and install vscodethen gotohttps://platformio.org/platformio-ideand click install for vscodeonce 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.pdfin the setup function put thisCode: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.3vvoid setup() {// put your setup code here, to run once:pinMode(PIN_LIGHT,OUTPUT);digitalWrite(PIN_LIGHT,LOW); //LED comes via 3.3vfor (int count=0;count<100;count++){delay(100);digitalWrite(PIN_LIGHT,HIGH); //turn off led0delay(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

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: December 28, 2021, 08:54:37 pm
content: 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........

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 29, 2021, 06:10:42 am
content: Quote from: Quarlo Klobrigney on December 28, 2021, 08:54:37 pmOdd, 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

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: December 29, 2021, 06:28:22 am
content: 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,tomorrowtoday 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.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 29, 2021, 06:55:25 am
content: 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 = buildctrl+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)

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: December 29, 2021, 11:10:56 pm
content: 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.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 30, 2021, 08:37:21 am
content: 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 stmcubefrom there we can add lcd features (i've done this a LOT and have some good tricks)darkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: December 30, 2021, 08:49:28 am
content: I don't think so, but what do I know. Whatever you can do to help, I appreciate it.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 30, 2021, 10:28:07 am
content: 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: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 */}/

author: DavidAlfa
author_rank: Super Contributor
timestamp: December 30, 2021, 11:00:41 am
content: Code wrongly placed! Anything after "USER CODE END" will get wiped on MX code generation

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 30, 2021, 11:15:52 am
content: Quote from: DavidAlfa on December 30, 2021, 11:00:41 amAh ok, I dont use cubeide myself so didnt know about thatmy 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 interactiondarkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: December 30, 2021, 12:23:25 pm
content: 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:/* 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 */}

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: December 30, 2021, 12:37:28 pm
content: I did change you clock paths to reflect the following:

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 30, 2021, 12:46:08 pm
content: Quote from: Quarlo Klobrigney on December 30, 2021, 12:37:28 pmYes, 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.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 30, 2021, 12:52:57 pm
content: Quote from: Quarlo Klobrigney on December 30, 2021, 12:23:25 pmI 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

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: December 30, 2021, 01:06:57 pm
content: 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.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 30, 2021, 02:38:29 pm
content: 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 anewtip 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

author: DavidAlfa
author_rank: Super Contributor
timestamp: December 30, 2021, 03:04:11 pm
content: 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.

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: December 30, 2021, 06:06:14 pm
content: 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 asCode:void ili9341_DisplayOff(void){ILI9341_LCDMUTEX_PUSH();LCD_IO_WriteCmd8(ILI9341_SLPIN); // SleepILI9341_LCDMUTEX_POP();LCD_IO_Bl_OnOff(0);}

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: December 30, 2021, 06:14:39 pm
content: 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.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 30, 2021, 06:34:55 pm
content: Quote from: Quarlo Klobrigney on December 30, 2021, 06:06:14 pmif you down to 247 errors then you still proving my point, you are running to compile untested/random code into your project just for a lcd.If you can blink a led using the HAL_ code then next step is confirming the FSMC setup , tthen writing the 3 ILI commands that activate most lcds. it's all doable in the basic file i gave you without USING ANYONE ELSES CODE.

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: December 30, 2021, 06:47:00 pm
content: And I already said it complied on 2 different compilers and blinked the 2 LEDs and the LCD backlight.I was then that you wanted to jump ship to Platform IO. I don't understand. If I've confirmed your code then where is the issue with doing as you ask?

author: DavidAlfa
author_rank: Super Contributor
timestamp: December 30, 2021, 09:38:04 pm
content: Post your code folder if possible and I'll have a look.I bet you're forgetting to add some folder to the compiler include path or something like that.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 31, 2021, 07:31:09 am
content: eevblog_files.zip(706.03 kB - downloaded 94 times.)Quote from: Quarlo Klobrigney on December 30, 2021, 06:47:00 pmApologies, was a stressfull day.find attached a zipped project for CubeIDE , find the define EEVBLOG , this switches between your board and the 407 i'am currently using (MKSTFT3.5 3d printer panel)comment out the define with // to switch to my board config,it should work out of the box with maybe the lcd backlight (LCD_BL) polarity being wrong , this is a minimal config so no fancy gfx code included, just the absolute basics to config the fsmc, enable backlight , init screen and send blue to the buffer.also the EEVBLOG defines will show you the changes needed between board types so in future it will be easier to use code from other sources and know what to change to port to your board of choice.darkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 01, 2022, 06:35:21 pm
content: The code you kindly provided originally left a black screen.So I checked PB1's and it was low.After a few hours of rest, I found your comment and reversed the polarity on PB1 and commented out the if statements to avoid my confusion and the backlight was lit.Fast forward 10 minutes and waiting a bit, the screen is not displaying anything.The code that does display the test screens but nothing other than white screens of a timed nature is from:http://www.lcdwiki.com/res/Program/Parallel_Port/3.2inch/16BIT_ILI9341_MRB3205_V1.0/3.2inch_16BIT_Module_ILI9341_MRB3205_V1.0.zipThe demo when unzipped lies at the path of: Demos\3.2inch_16BIT_Module_ILI9341_MRB3205_V1.0\1-Demo\Demo_STM32\Demo_0_STM32F407VET6. It is totally configured for another device, although labelled STM32F407VET6.Not only that, but comments like"(GPIOA,GPIO_Pin_1);// initialize GPIOF9, F10 setting high, light off"don't do anything to inspire confidence or calm.Also anything that was commented was in Chinese which required long sessions traversing back and forth between Notepad++, Google and the IDE to sort out.I did find a YouTube video from Mutex Embedded, a guy in Morocco who showed how to do an 8 bit FSMC which although displaying text, symbols and a photo, it looks cartoonish like "3-1/2 bit color" but it does work to show anything but a white screen."STM32F4 Discovery board - Keil 5 IDE with CubeMX - Tutorial 21 - TFT LCD ili9341 (using FSMC)"All other Chinese "examples" fail.To compound my miseries, I made a bad mistake of using a common storage folder for all build hex files so I could use STMCube Programmer without searching for where the hex files were at. It destroyed several progressing "better" LCD hex files. This happened when I compiled an unrelated Arduino project, which used the common hex folder. I had the Arduino build output set to this folder. It totally wipes the folders contents out.I have relearned not to stress out "much" but it is a trait from when I was under the gun when I was still working and not retired as I am now.

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 01, 2022, 06:44:41 pm
content: Here are some examples of the LCD I have from various vendors. All of these are direct pin-for-pin compatible direct plug in without wires to the STM32F407VET6 board. No shortened URLs as I like to see where I'm being directed to and I think you do too.https://www.aliexpress.com/item/32977663446.html?spm=a2g0o.search0302.0.0.5c872274MSRVnp&algo_pvid=4479b8df-41d6-494e-8196-87a5b72acaa7&algo_exp_id=4479b8df-41d6-494e-8196-87a5b72acaa7-7https://www.aliexpress.com/item/1005002383360549.html?spm=a2g0o.search0302.0.0.5c872274MSRVnp&algo_pvid=35ed8076-9f3d-42a4-9a96-7f0d81595ed2&algo_exp_id=35ed8076-9f3d-42a4-9a96-7f0d81595ed2-52https://www.aliexpress.com/item/32662835059.html?spm=a2g0o.search0302.0.0.5c872274MSRVnp&algo_pvid=64ac694c-074c-4fad-84bb-f3b024c00560&algo_exp_id=64ac694c-074c-4fad-84bb-f3b024c00560-28https://www.aliexpress.com/item/32991977705.html?spm=a2g0o.search0302.0.0.5c872274MSRVnp&algo_pvid=64ac694c-074c-4fad-84bb-f3b024c00560&algo_exp_id=64ac694c-074c-4fad-84bb-f3b024c00560-40https://www.aliexpress.com/item/4000953664266.html?spm=a2g0o.search0302.0.0.5c872274MSRVnp&algo_pvid=64ac694c-074c-4fad-84bb-f3b024c00560&algo_exp_id=64ac694c-074c-4fad-84bb-f3b024c00560-48The board and LCD pinout:▄ ---------GND | 1 2 | NRST/RSTFSMC_D15/PD10 | 3 4 | PD9/FSMC_D14FSMC_D13/PD8 | 5 6 | PE15/FSMC_D12FSMC_D11/PE14 | 7 8 | PE13/FSMC_D10FSMC_D9/PE12 | 9 10 | PE11/FSMC_D8FSMC_D7/PE10 | 11 12 | PE9/FSMC_D6FSMC_D5/PE8 | 13 14 | PE7/FSMC_D4FSMC_D3/PD1 | 15 16 | PD0/FSMC_D2FSMC_D1/PD15 | 17 18 | PD14/FSMC_D0FSMC_NOE/PD4 | 19 20 | PD5/FSMC_NWEFSMC_A18/PD13 | 21 22 | PD7/FSMC_NE1T_SCK/PB13 | 23 24 | PB12/T_CST_MOSI/PB15 | 25 26 | PB14/T_MISOPEN_IRQ/PC5 | 27 28 | PB1/LCD_BLN.C. | 29 30 | GND3V3 | 31 32 | GND---------

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 01, 2022, 08:07:32 pm
content: After adding-changing a few pins, clock sources and accepting migration to the newer FW version, I can report that now the screen is white at startup then goes to blue. See the MX report enclosed.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 01, 2022, 11:23:44 pm
content: Quote from: Quarlo Klobrigney on January 01, 2022, 08:07:32 pmThat is good progress, can you post the changes you made or better repost the files then others can use the code.darkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 01, 2022, 11:45:33 pm
content: Was your intention to make a blue screen?

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 02, 2022, 08:02:00 am
content: My Intention was to get the most basic of lcd operations going without having the source filled with routines that would confuse you. further down the line you might find yourself hacking a commercial device for fun or profit and the most basic things you can do is 'hello world' via the device's various IO, in our case we made lcd blue(value was random) with the option of printf, you will note the syscalls.c file and the PUTC defines.we can now either take the FSMC setup routines, writing routines and transfer them to other projects or mod the other projects to reflect this setup.I do see my mistake in the RCC/Clocks setup and now am wondering why mine worked but yours did not, it also explains why i was not getting the correct HAL_Delay values, small oversight but we got to the target anyway.darkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 02, 2022, 11:41:18 am
content: I still have no idea why the screen is blue from your code. Please explain.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 02, 2022, 02:15:42 pm
content: Quote from: Quarlo Klobrigney on January 02, 2022, 11:41:18 amIn the routine lcd_fill_col() (line 206) it first sets the point of memory to write the data then using the next routine lcd_data16(colour); it fills the buffer memory with the value in colour

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 02, 2022, 11:58:54 pm
content: I still don't understand. No matter what HEX value is substituted, the screen remains blue. It's like when Henry Ford "invented" the first car, he said "you can get any color you want as long as it's black". It appears to be Intensity rather than Color.I changed the LCD size to accommodate my 3.2" version 320x240.Code:void lcd_fill_col(){uint16_t colour = 0xFFFF;lcd_setwindow(0,0,240,320); // 480,320lcd_cmd16(ILI9341_RAMWR);for (int x=0;x<320;x++)for (int y=0;y<240;y++) // for (int y=0;y<480;y++){lcd_data16(colour);//HAL_Delay(100);//lcd_data16(colour);}}

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 03, 2022, 12:20:52 am
content: I have used other ILI controllers, not this particular one. But I would guess that maybe the display initialization is not correct. For instance, the pixel format.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 03, 2022, 07:00:51 am
content: Quote from: Quarlo Klobrigney on January 02, 2022, 11:58:54 pmThat because i wrote this sample code in about fives mins and uploaded for you to "test" your lcd with, as a result i made a few mistakes, example is the routine lcd_data16() , if you look at the routine it actually accepts a uint8_t number, not the actual uint16_t number that was ment to be there , truth is this code was not ment for anything more that test the lcd/board.originalCode:void lcd_data16(uint16_t data){*(uint8_t*)DataAccess = data;}fixedCode:void lcd_data16(uint16_t data){*(uint16_t*)DataAccess = data;}there are more errors in my example code but the code itself was throw away, not ment for projects. Also some LCD's require the right mapping of colour be it BGR or RGB to be set, i didnt do this in the code.you can see further details in the lcd manual ,https://cdn-shop.adafruit.com/datasheets/ILI9341.pdftruth is there is more to configure when using ILI type screens , pixel format is just one of the many settings, 8-bit/16-bit mode is another.darkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 03, 2022, 07:24:04 am
content: Thanks for the reply and the fix. It now does various color shadings as it was intended.My next favor, is where would I insert the hex code to display a photo.I know how to convert the photo, but just where to insert it in main.This would serve to test the LCD's ability to actually show a picture not in cartoon mode.I never intended to use it for anything other than to learn how to do it on my own.If you could do this I would appreciate it very much. I'm old and slow but determined. Thanks.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 03, 2022, 10:56:34 am
content: Quote from: Quarlo Klobrigney on January 03, 2022, 07:24:04 amif we create another routine and input the hex data (i assume from either a array in memory or a pointer in memory )like soCode:uint16_t picture_array_data[] = {0,10,11,12,13,100,20};// array containing picture data (note example data provide, this wont work without being replaced with actual data )void lcd_do_picture(void){uint8_t count=0;//set counter to start of memory arraylcd_setwindow(0,0,480,320); //this set the window size for data write#ifdef EEVBLOGlcd_cmd16(ILI9341_RAMWR);//ILI9341 and ILI9488 use same values for this#elselcd_cmd16(ILI9488_RAMWR);#endiffor (int x=0;x<320;x++)for (int y=0;y<480;y++){lcd_data16(picture_array_data);//this take data from stored image location and outputs to the RAM register of LCDcount++;//increment count}}this is a rough and dirty bit of code that takes bitmap data in a memory array and outputs to the lcd starting at X=0,y=0 and continues until the end of the array,you will need to make sure source image is in correct format when stored in the code, some conversion will provide RGB values as separate valueseg picture_data[] =(R,G,B) = 1 pixel valuebut our lcd's need a combined value RGB as one number, eg 0xff00ff , this is also depended on the settings of your LCD, as per the data sheet you can switch between GBR values and RGB.again this is rough code i'am writing on the go and is not tested.darkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 03, 2022, 11:21:54 am
content: Sort of.....So where is the "injection point"? Is it in main, and how would it be called in the while loop?

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 03, 2022, 03:30:51 pm
content: Quote from: Quarlo Klobrigney on January 03, 2022, 11:21:54 amit should be in main , it's up to you if you want to call it once (in main) or many times ( while loop) ,darkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 04, 2022, 05:52:52 pm
content: I haven't tried inserting the array code yet because I wanted to understand why all the demos had failed.I always wondered why there were 2 sets of resistors, 3 together, that were stacked high and low on the backside of the TFT.I got busy in the ILI9341 manual and the first thing I noticed is no bookmarks, After 30 minutes of my life wasted making chapter and sub chapters in the PDF, I had my answer for what those resistors could doing.Taking out the latest in superb Chinese technology multimeter as I didn't want to goose the TFT with 9V from my old Fluke, I probed the top and bottom rails of the board to ground and 3V3.What I found was very logical. The top rail was 3V3 and the bottom ground.Finding the TFT's 40 pin FPC pinout explained further. The last few pins 37-40 were the IM[3-0] config bits.On my panel, all IM bits are grounded. The resulting configuration is 8 bit mode D7-0, not 16 bit!I'll try to move the 5K1 resistor on bit IM0 to 3V3, in accordance to the config chart to make it 16 bit.

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 05, 2022, 04:50:43 am
content: Well that was hardly productive.After removing and replacing the 603 resistor on the right (IM0) and testing the solid color example,I noticed it didn't workSo in order to test all configurations, I removed all the resistors and made a 6 x 2 header with 3 pins of the bottom row going to GND, then the other 3 going to 3V3.The header was JB Welded to the LCD board.The top row of 6 is broken into 3 sets of 2, i.e. #1 & #4 are IM0, #2 & #5 are IM1, and #3 & #6 are IM2.In this way, adding a jumper to the left bank sends IM# to 3V3.Adding it to the right sends IM# to GND.I inserted something more visible in size: 3 1206 5K1 resistors, 1 in each IM# leg going to the LCD board original pad.IM0 IM1 IM2 | IM0 IM1 IM2x x x | x x xx x x | x x x Connect a vertical jumper on each IM# left or right position.|--3V3--| | |--GND--| Only one jumper for each at a time.Photo(s) to follow.It's time for

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 05, 2022, 02:51:45 pm
content: Quote from: Quarlo Klobrigney on January 05, 2022, 04:50:43 amwhat was shown on lcd after the change ? a gray/white is normal the config has not set,darkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 05, 2022, 07:37:00 pm
content: Now that I'm awake I can think a little better. What was shown in all permutations of the jumper swaps was nothing but a blank white screen with some initial flashing but steady gray after a half second with no change after.I'd like to know what R1 - R6 & R4 - R7 do. I still don't know.Here are some photos of the "quick and still dirty" IM config test mod but they do work. They will be cleaned up later.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 06, 2022, 09:44:03 am
content: Quote from: Quarlo Klobrigney on January 05, 2022, 07:37:00 pmthis might shed some light on the issue, if you scroll down to where is states which resistors to swap for 8/16 bit mode, it shows in 16 bit data d0-d15 is used but in 8-bit d10-d17 is used, in my code i added a data shift to raise the lower 8 bit higher, you might need to remove that for 16 bit modedarkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 06, 2022, 12:55:45 pm
content: If you can help, I'd like to know how.That kind of knowledge escapes me.With a 245 page datasheet, the idea that I could ever understand the concepts seems overwhelming.I a heading to the idea that I won't be ever able to understand and should just throw it in a box and give up.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 06, 2022, 01:24:32 pm
content: Quote from: Quarlo Klobrigney on January 04, 2022, 05:52:52 pmOk before we go down the bit shift rabbit hole I relooked at a few ILI9341 boards and manuals and not all pinouts are the same so its only a assumption that yours matches exactly.Could you be reading the Bits backwords ? eg IM0=IM3 in which case you are switching to 16bit mode 2, this requires the bits being shifted e.g "Data = Colour <<8|Colour;"I also see that there is R1/4/6/7 which also seems to be 0ohm resistors for selection so that mean we now have 5 bits not just 3 bits you originally saw.Also why is it so important that it must operate in 16bit mode ? it was working fine in 8 bit and you should use that to gain experience with the lcd or with programming lcd's in general, have some fun learning to code before you whip out the old 85watt wella and start causing yourself more work, personally i would learn bitbashing the 8 bit bus before you try to complicate the issue.darkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 06, 2022, 05:51:37 pm
content: Here is the actual seller:https://www.aliexpress.com/item/32991977705.html?spm=a2g0o.9042311.0.0.762d4c4dfXfR0DOnly this black board should be used when referencing the FFC pinout.pin 37 - IM 3 is grounded through a via as well as the previous 2 pins 35 & 35, making FSMC 16 II impossible to achieve.The other resistors are on pins 17 & 18 - (DB0 & DB1)I need the 16 bit mode because it fits on the 407VET board pin for pin and 16 bit mode is desirable for speed for one point and I don't know if resolution is at play or not.I don't why the China and other provided examples don't work...the all say they except the don't.Please if you can help with a working example as this would take a year or more for a dimwitlike me to understand.FFC Pin#/Function17 18 17 = DB0| | 18 = DB1▄ ▄R6 R7____▄ ▄| |____? ? = Disappears through a micro via to parts unknown| 13 | 13 = SPI SDI/SDA| ▄| ▄| R1 R4|___▄ ▄____14 14 = SPI-SDO

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 07, 2022, 06:13:16 am
content: Quote from: Quarlo Klobrigney on January 06, 2022, 05:51:37 pmIn order to confirm your findings we are going to have to run some test's. This means writing test code designed to replicate the FSMC function but diving us more control. That is not easily done , we also need you to understand the bus a little more so you in turn understand things like bit shifting, bit bashing as thats needed in your lcd case.In the manual it states that in 8 bit mode the UPPER 8-bits are used, in 16 then the upper and lower 8 bits are used. This means we need to reverse the bits when *writing in the different modes ,so 0xFFAA becomes 0xAAFF , that is the lower 8 bits of OUR data get push to the top and the top goes to the bottom.see this page that also mentions is,http://www.lcdwiki.com/3.2inch_16BIT_Module_ILI9341_SKU:MRB3205another thing mentioned in the manual is we can read data, including the model number and ID's, this is good as we can use this to test the databus (confirm your findings too)So lets first look at the read function as we know what it should give us hex value 0x93 and 0x41in 16 bit mode thats one read of LCD and we should have two reads, one dummy byte and then actual 16 bit data,e.guint16_t dummy=0x0uint16_t value = 0x9341and in 8 bit mode it should beuint8_t ID1 = 0x0uint8_t ID2 = 0x41uint8_t ID3 = 0x93which is three readsin real code it could be something like thisCode:uint8_t readData8(){return *(uint8_t*)DataAccess;}uint16_t readData16(){return *(uint16_t*)DataAccess;}so there are our code parts for the read data primary function, no we have to add more code to do actual readsCode:uint32_t readID(){return readRegister(0xD3, 0, 3); // 0xd3 is second ID register, 0x04 is first}uint32_t readRegister(uint8_t nr, uint8_t index, uint8_t bytes){uint32_t rv = 0;bytes = 4;writeCommand(nr);readData(); // dummyfor (uint8_t i = 0; i < index; i++){readData(); // skip}for (; bytes > 0; bytes--){rv <<= 8;rv |= readData();}endTransaction();return rv;}so once you have added the above code then in main you addHAL_UART_write(readID());and it should print out via serial port (if you have set it up that is, if not you should as its vital part of debug)darkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 08, 2022, 01:34:11 pm
content: Before I try that, Platform IO was given another shot. The downloads on Microsoft's web page for Windows don't all work or are behind in revision. Nothing that I download will recognize the path to Arduino.h, Every search is all questions but no answers or people saying it's a bug. Any insight and what version do you have?

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 08, 2022, 02:31:47 pm
content: Quote from: Quarlo Klobrigney on January 08, 2022, 01:34:11 pmCan you check you have follwed everything this guidehttps://docs.platformio.org/en/latest/integration/ide/vscode.htmlnormally when vscode says is cant find Arduino.h is means platformio is not installed into vscode.my vscode version isVersion: 1.63.2 (user setup)Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3Date: 2021-12-15T09:40:02.816ZElectron: 13.5.2Chromium: 91.0.4472.164Node.js: 14.16.0V8: 9.1.269.39-electron.0OS: Windows_NT x64 10.0.19044darkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 08, 2022, 02:52:00 pm
content: Same version, I downloaded VS Code, added Platform IO from the left panel... and still the error. I did uninstall it a few times and reinstalled. The last reinstall was with the Chocolatey package manager,https://chocolatey.org/still no help. I like Chocolatey because it does official packages as well as version compatibility.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 08, 2022, 03:03:49 pm
content: In your platformio.ini file do you haveframework = arduinoorframework = stmcube ?

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 08, 2022, 03:18:29 pm
content: Using the code you provided waaay back:[env:genericSTM32F407VET6]platform = ststm32board = genericSTM32F407VET6 // black_f407veframework = arduinolib_deps = mbed-hudakz/ILI9341_STM32F4@0.0.0+sha.5c2870105122upload_protocol = stlink

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 08, 2022, 03:38:06 pm
content: Quote from: Quarlo Klobrigney on January 08, 2022, 03:18:29 pmcan you remove the " //black_f407ve" and try and compile again, it may be interfering with the process as in the ini file only ; is allowed for comments.another trick to try is a blank arduino project with no other code (using platformio home screen)darkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 08, 2022, 03:49:54 pm
content: Still waiting to make a new project as the "default" folder is not where I want it to be. It's stuck on please be patient.It needs an internet connection to change the project folder.That does not give me confidence that this program is not stealing info. After this test I may make it go away.

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 08, 2022, 03:53:58 pm
content: It still has the squigglies. It's an ongoing problem.#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit "\Platform IO Projects\src\main.cpp)".[env:uno]platform = atmelavrboard = unoframework = arduinoCode:#include <Arduino.h>int PIN_LIGHT = PIN_A7; // we define out LED0 here// LED0/LED1 HIGH/LOW value inverted due to MCU providing drain/GND for led and not source/3.3vvoid setup(){ // put your setup code here, to run once:pinMode(PIN_LIGHT,OUTPUT);digitalWrite(PIN_LIGHT,LOW); // LED comes via 3.3vfor (int count=0;count<100;count++){delay(100);digitalWrite(PIN_LIGHT,HIGH); // turn off led0delay(100);digitalWrite(PIN_LIGHT,LOW); // turn on led0 }}void loop(){ // put your main code here, to run repeatedly:}

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 09, 2022, 05:57:28 pm
content: Quoteyour platform is wrong for a start if that is the one you are using, also you wont get plugins like code following and such until you actually install them, the key point is when it's correct does it compile ? the code following is a feature we can chase later but if your platformio.ini is wrong then you will not go much further.When starting a new project , type the name and then in the BOARD text box type stm32f407ve , scroll until you see genericstm32f407ve and select that, then once in the project click the build icon which is a tick mark in lower left corner , next to it is upload and clean.my playformio.ini on blank 8mhz chipped 407ve for arduino is as follow'sCode:[env:genericSTM32F407VET6]platform = ststm32board = genericSTM32F407VET6framework = arduinodarkspr1te

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 09, 2022, 06:44:49 pm
content: It's not wrong, what do you think I already had in #59?You asked me to try with Arduino.I did and that was the setup that still failed finding Arduino.h.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: January 09, 2022, 09:45:59 pm
content: then i give upyou seem setup for fail, you wont post a singled bit of data that covers anything apart from a re post.am out, ive written enough code here.darkspr1te out

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 09, 2022, 10:26:31 pm
content: I don't know what to say. I have done what you have asked. I still don't understand how to run PIO but I do know that Arduino.h has squiggly lines under it because it cannot find the path and I can do nothing to correct the issue.

author: Bud
author_rank: Super Contributor
timestamp: January 09, 2022, 10:58:59 pm
content: Is a way in yiur IDE to specify Include and Source paths? Like in Project Properties or something. Try adding a path to where that header resides.

author: Quarlo Klobrigney
author_rank: Super Contributor
timestamp: January 09, 2022, 11:41:55 pm
content: Yes I did I added the whole path with <> and or "" and it still protested.That's why I did a simple Arduino Blinky and it failed as well.I do not understand how to open a previous project in Platform IO after it has been already been saved. They show up on the left pane but I cannot just do an "open project"I saw no easy way for me, but I don't use the program I was trying to accommodate DarkSpr1te if he wanted to program in that platform.One has to know how to use PIO and I don't have much luck getting the IDE to behave.Even after uninstalling, and reinstalling it remembered all my settings. Not a good thing. It also wanted to share my project after repeatedly saying no.

author: Bud
author_rank: Super Contributor
timestamp: January 12, 2022, 07:33:37 pm
content: It may be another header file that Arduino.h referenced inside that could not be found, I've seen this type of nested errors .