Showing results for 
Search instead for 
Did you mean: 

REPOST: HW Integration with TouchGFX

QUESTION - TouchGFX Community repost - Bharathi Sara - Sep 2018

​I have watched the HW integration video and yet I am still confused. I am using the i2c pins on my STM32F769I-DISCO board. I would like to collect data from that pin and display it on my gui. As far as setting it up goes, I've already managed to collect data just using CubeMX and Keil. I didn't have the change any config on CubeMX.

I understand that I will have to write RTOS tasks to collect data from peripherals. My question is where do I place relevant CubeMX files? And as generated by CubeMX there is a main.c method that has a lot of variables and initialization methods that I use defined in main.c. are those functions are variables defined somewhere in the TouchGFX framework? If not do I need to copy them over into my relevant task?

For example in order to use i2c, I need to use the i2c handler hi2c1 and the MX_I2C_init() function. This function's implementation is later defined in the main.c class when working through cube and Keil. Is this something I have to transfer over as well? I also use a lot of HAL functions provided by the CubeMX libraries to read and write to I2C, do I need to add these files as well?

If so where do these files go? And how do I compile everything? Can I use Keil to compile and load or should I use GCC and update something on the make file?

I've tried to use your examples and webinar but I'm still confused on the overall structure of things.

ANSWER - TouchGFX Community repost - Martin Kjeldsen - Sep 2018


Take a look at

and see if that helps you integrate CubeMX generated files and TouchGFX. Your confusion is probably how to integrate new cubemx files into an existing touchgfx demoboard project. I think you'll get some hints from that short article.

The demo board projects all use older versions of Cube drivers and have not been generated directly by using CubeMX. If you just want to enble I2C or a different peripheral i think you should look innto the cube pack examples for that demo board rather than using CubeMX to generate new code.

Let me know how you do.

ANSWER - TouchGFX Community repost - Bharathi Sara - Sep 2018

This seems to be what I've done. I am initializing the I2C using the same methods provided through CubeMX. I essentially just copy pasted all the code into my main method and wrote the task for the initialization of the i2c peripheral. For some reason I found that the i2c itself was not being initialized when debugging. Is there any way I can send you my code?

ANSWER - TouchGFX Community repost - Martin Kjeldsen - Sep 2018


Since I2C initialization is not TouchGFX specific, i'm not sure this is the right forum to ask. But, you're correct that you need to call all the init methods provided by Cube/CubeMX - TouchGFX does not know anything about boards or genneral purpose peripherals, but lets you call any code you want before starting TouchGFX.

Have you checked out the I2C examples in the Cube driver packs? (Not through CubeMX). I think this is the way to go and not using CubeMX to generate new code, since that code already exists in the BSP for your Disco board.

ANSWER - TouchGFX Community repost - Bharathi Sara - Sep 2018

What exactly do you mean by Cube driver packs? Where can I find these examples?

I am using the MX_I2C1_Init() functions for initialization. And the HAL_I2C_Master_Transmit() and HAL_I2C_Master_Receive() for I2C communication. All this code works fine while just programming on Keil without TouchGFX or the screen running.

However, when I copy paste that code into TouchGFX, for some reason the I2C is not being initialized. I am using I2C1 PB9 and PB8 for reading the sensors. I noticed that the screen is on I2C1 as well, but I believe those are different pins (PD12 and PB7). Just want to confirm that as well.