cancel
Showing results for 
Search instead for 
Did you mean: 

Getting started with TouchGFX and bringing up a board

BWKidd
Associate III

Hi All,

I'm trying to get started with TouchGFX.

I'm currently working with a NUCLEO-L496ZG eval board connected to an NHD-2.8-240320AF-CSXP-FT (320 x 240 TFT LCD with ST7789 internal controller.)

I've successfully connected up the display via FMC and been able to display colors and images and such to the screen, just using statements like 

*(__IO uint16_t *)(0x60000000) = command;

*(__IO uint16_t *)(0x60020000) = data;

to send data to the command and data registers, and everything seems to be working well.

Now I'm trying to bring in TouchGFX into the mix and I'm having a difficult time. I've read through the board bring up process, and where I think I'm having trouble is knowing which functions to modify from the generated code to integrate the ST7789 driver code I've written.

To give you an idea of what I've tried and what my setup is, here's what my TouchGFX setup looks like in the IOC:

BWKidd_0-1709759336646.png

After generating the code, I used TouchGFX designer and opened the ApplicationTemplate.touchgfx.part file and then added a simple splash bitmap to the default screen:

BWKidd_1-1709759709814.png

(I know, I could quit being an electrical engineer and draw pictures in paint for a living, right?)

I then generated code, went back to STM32CubeIDE re built with no errors.

On first debug session, nothing happened on the LCD, which makes sense since I hadn't modified any of the generated code. Based on the example here FMC and SPI Display Interface | TouchGFX Documentation I realized I was probably supposed to modify flushFrameBuffer in the TouchGFXHAL.cpp file, so I did so like this:

void TouchGFXHAL::flushFrameBuffer(const touchgfx::Rect& rect)

{

// Set Cursor

TFT_setAddress_WidthHeight(rect.x, rect.y, rect.width, rect.height);

TFT_flushFrameBuffer(frameBuffer0);

}

That didn't make any difference, and I noticed that setting a breakpoint within this function, the flushFrameBuffer function doesn't seemed to get called anyways, and it was at this point that I realized there is too much I don't know/ don't understand. I don't even know of "frameBuffer0" points to the frame buffer I created in the TouchGFX part of the IOC file. According to a note in there, the framebuffer is supposed to be called "framebuf" but the compiler doesn't recognize that.

I realize that I'm missing a big chunk of knowledge here, so please forgive my ignorance. Could someone point me in the right direction?

14 REPLIES 14
GaetanGodart
ST Employee

Hello @BWKidd ,

 

First of all I have to say that I am quite impressed by your paint masterpiece!

 

Regarding your TouchGFX issue, I will do my best to assist you.

Can you explain how you were able to display colors and images using FMC.
I assume you wrote the data and commands using the HAL FMC functions. I assume that "0x60000000" is the memory address for the command register that you mentioned in STM32CubeMx in the FMC section (same for data on memory 0x60020000).

1 )
What is your Data size (8 or 16 bits) ?
I think that for 16 bits it should work with FMC interface but for 8 bits it has to be custom and the functions must be modified.

2 )
Let's try first to no modify the generated functions.
Also maybe try with a simple colored box first.

3 )
You can create projects using the H5 boards.
Some uses FMC 8 bits with custom interface, others uses FMC 16 bits with FMC interface :

GaetanGodart_0-1709817097534.png
You could get inspired by those and look if they have something different than yours.

 

4 )

What is your compiler?
Do you generate code from STM32SubeMx selecting the STM32CubeIde toolchain?
Somehow your "Flash" button (in the bottom right corner) in Designer is not pink, doesn't look clickable, it would be easier in the beginning to flash from Designer

 

5 )
Also, could you share you ioc file?

 

Regards,

 

 

Edit : 
The STM32H573I-DK_EXT-FLASH (the second from the left) that is using 8 bits data and custom interface is using the same driver as you.
Data sheet found on digikey (Digikey link for your screen ) link to the driver datasheet : Driver ST7789V datasheet 
And This is the screen used in the application, according to the file TouchGFXHAL.cpp :

GaetanGodart_1-1709818091915.png

You can find the TouchGFXHAL.cpp file in the project folder path ProjectName\TouchGFX\target\.

 

Find attached a zipped file of the project STM32H573I-DK_EXT-FLASH.

Gaetan Godart
Software engineer at ST (TouchGFX)

Hello @GaetanGodart ,

Thank you for your complements on my artwork :)

I'm using STM32CubeIDE Version 1.14.1, and I'm using TouchGFX Designer 4.23.0. I created my project, ioc, etc using the CubeIDE, and then opened the .part file in Designer to add that bitmap. I see what you mean about the launch button not being clickable. I'll take a look at the sample projects that you sent and try starting a new project from Designer.

To give you a little more detail on how I'm able to communicate with the display using the FMC without using TouchGFX, I've got the FMC setup like so:

BWKidd_0-1709819257225.png

Specifically, i'm using 16 bit mode.

My hardware connections are as follows:

BWKidd_1-1709820784004.png

To communicate with the display via FMC, I've defined two helper macros:

 

 

 

#define TFT_writeCommand(command) (*(__IO uint16_t *)(0x60000000) = command)
#define TFT_writeData(data) (*(__IO uint16_t *)(0x60020000) = data)

 

 

I initialize my display in the setup portion of void main() like so:

 

 

 

HAL_GPIO_WritePin(DISP_RES_GPIO_Port, DISP_RES_Pin, GPIO_PIN_RESET); // Activate Reset (Reset = Low)
HAL_Delay(100);
HAL_GPIO_WritePin(DISP_RES_GPIO_Port, DISP_RES_Pin, GPIO_PIN_SET); // Reset line to HIGH
HAL_Delay(100);
TFT_writeCommand(SLPOUT);//exit SLEEP mode
HAL_Delay(100);

//MADCTL: memory data access control
TFT_writeCommand(MADCTL);
TFT_writeData(MX+MV);
... etc

 

 

(i'm happy to provide the full code if that helps, but its just fairly standard ST7789 driver stuff)

And then I can color the screen blue (for instance) by doing something like this:

 
 

 

 

//X address set

TFT_writeCommand(CASET);
TFT_writeData(0);
TFT_writeData(0);
TFT_writeData(0x01);
TFT_writeData(0x3F);

//Y address set
TFT_writeCommand(RASET);
TFT_writeData(0);
TFT_writeData(0);
TFT_writeData(0);
TFT_writeData(0xEF);

TFT_writeCommand(RAMWR); // Memory Write

const uint16_t colorWord = 0x001F; // RGB565 Blue

for (unsigned long b = 0; b < 320*240; b++) {
 TFT_writeData(colorWord);
}

 

 

I've attached my IOC file.

It will probably be a few days before I get a chance to dig into those examples and try recreating the project, but when I do, I'll post what I find. Thank you so much for your responses and advice!

GaetanGodart
ST Employee

Hello @BWKidd ,

 

Have you had the opportunity to spend some more time on your project?

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

@GaetanGodart ,

Thanks for checking in on me! I did managed to start converting the code in the TouchGFXHAL.cpp file of the STM32L496G-DISCO example project over (the one that uses 16-bit FMC with the ST7789H2), but have not yet successfully completed that. I'm hoping to have something to try in another day or two...if people will stop coming in my office and asking me to do stuff!

I'll post an update once I either have something working or have driven myself mad from frustration.

GaetanGodart
ST Employee

Haha sounds good!

Talk to you soon.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

Hello @BWKidd ,

 

Just checking in if you had some alone time to work on your project! :beaming_face_with_smiling_eyes:

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

@GaetanGodart 

Sigh...unfortunately I've only been getting about 10 to 15 minutes to work on this per day due to some other projects, which hasn't been enough to get anything working.

What I have found so far is that I can get my ST7789 code to work, though not in the TouchGFXHAL.cpp file yet, but I cannot get STM's st7789h2 code to work - it seems like it isn't actually interfacing with the FMC, though I haven't yet verified this.

Anyways, I appreciate you checking in on me. I'll try to have something more substantial to report soon. I think the next thing I am going to try is substituting my code into the TouchGFXHAL, though I need to do some re-writing to accomplish that.

@GaetanGodart 

I've started the process of adapting my driver code to work with TouchGFXHAL.cpp, but what I'm running into is that TouchGFXHAL::flushFrameBuffer() never gets called. Shouldn't this function be called every so often? I'm probably revealing the depth of my ignorance here, but i'm guessing there's some type of tick routine that I need to implement, as the TouchGFX configuration "Application Tick Source" is set to custom, and I'm not using an RTOS. I've included my IOC file and TouchGFXHAL files in case you want to look through them. Thanks!

Read some Real Time Operating System | TouchGFX Documentation

and for no os create timer simulator for vsync or use TE input as source...