2020-05-27 06:43 AM
I am using an STM32508 DK board and I am trying to press a button on the touch screen and gain a reading from an MCP3201 that is connected in the GPIO pins. I believe the code I have will work but when I put it into MainView for the button press the HAL GPIO commands are not recognized.
I am slightly new to using embedded microcontrollers this way and was wondering if it is possible to create a function that handles the GPIO commands in the main.c and then pull that function using MainView in TouchGFX?
2020-05-31 07:49 AM
Hi @DElli.1 ,
From what you have described I understand that you want to read from the MCP3201, which is an ADC, when the button on the screen is pressed.
So, essentially, you have to know that the button is pressed & in response to this event you want to read the ADC. You can use the interaction facility in the Designer software to create a new interaction. You will have to create a new function & give the name of this function in the interaction options.
The interaction can be added after selecting the button on the screen & adding the interaction from the top right ( indicated by a finger pointing icon ).
/Jagdish Bisawa
2020-06-01 06:44 AM
creating an interaction is not my issue. I can create interactions no problem but the problem lies in when I use those interaction functions to interact with the GPIO pins.
as soon as I write a command like HAL_GPIO_Write there is an error because it does not recognize the function. inside the view.cpp file.
2020-06-01 10:49 PM
Hi @DElli.1 ,
This appears to be more of a compiler isue, rather than the TouchGFX framework. The code for HAL_GPIO_Write(...) is in one of the STM32Cube firmware files. The declaration of the same is in one of the header files, supplied by the STM32Cube firmware.
So, what you have to do is make available these files in your project & indicate the path of these files to the Makefile of your project.
/Jagdish Bisawa
2020-06-02 06:05 AM
Keep HAL code out of your Views. If you're trying to run the program from the designer simulator you'll get an error for sure. If you insist, you need the proper includes to make those functions available to the compiler.
/Martin
2020-06-02 06:29 AM
I have been trying different includes but to no avail, I am new to the stm family and to projects as complex as this.
If the HAL code shouldn't be in views, I believe they only work in main.c.
Is it possible to create a function with HAL code in main.c and then export it to the views? And if this is not possible which includes would provide the functions to the compiler?
2020-06-02 06:32 AM
It's mostly that a nice seperation between gui code and backend code is preferred in terms of structuring projects. You can do it, just fine, though - Maybe start there until you can get it to work - Which compiler are you using? Are you maybe running this in the simulator through the designer?
/Martin
2020-06-02 09:08 AM
Project was started in TouchGfx and I am using CubeIDE.
I am using the designer to run to target.
2020-06-02 11:21 AM
Okay, still - You're calling some functions from your view that you need to introduce to the compiler. In the case of F7.
STM32F7xx_HAL_Driver\stm32f7xx_hal_gpio.h
/Martin