cancel
Showing results for 
Search instead for 
Did you mean: 

touch action problem

pabian
Associate III
  1. Initial screen
  2. Screen when the button 1 is pressed -> button 1 label pop up
  3. Screen when​ the button 1 is released -> top area of display is strange
  4. Screen when button 2 is pressed -> button 1 label pop up
  • Button 3 does not touch -> bottom area of display don't touch

What did I do wrong?

<Develop Environment>

  • Tool Chain: TouchGFX 4.14.0 + STM32CubeIDE 1.4.0 + CubeMX 5.5.0 (FW_F4_1.24.2) + FreeRTOS 10.0.1
  • H/W: STM32429I-EVAL
  • LCD: 3.5", 480 x 320 (SPI Init + RGB interface)
3 REPLIES 3
Romain DIELEMAN
ST Employee

Hi,

Could you elaborate a bit more what you are trying to do and how you programmed everything? Did you use the Interaction tab in TouchGFX Designer? We need more details to understand the issue and how to solve it. Maybe share more photos/code or the project.

/Romain

Here's what I did:

  1. create STM32CubeIDE 1.4.0 project with STM32429I-EVAL template (FW_F4_1.25.0)
  2. create TouchGFX 4.14.0 project with STM32F429I-EVAL template (FW_F4_1.24.2)
  3. integrate TouchGFX project into STM32CubeIDE project ( copy & paste of *.ioc, main.c, STM32TouchController.cpp/hpp, BSP folder and include path, generate code)
  4. Add or edit peripherals required to initialize the LCD in main.c (USART2, LCD clock, LTDC resolution, interrupt ...)
  5. Change ts_orientation = TS_SWAP_Y to TS_SWAP_XY (in STM32TouchController.cpp)
  6. Click ApplicationTemplate.touchgfx.part and add 3 buttons with label, then generate code (No other modifications have been made)
  7. build

The code below is main.c and STM32TouchController.cpp

/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "cmsis_os.h"
#include "app_touchgfx.h"
 
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
 
/* USER CODE END Includes */
 
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
 
/* USER CODE END PTD */
 
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
#define REFRESH_COUNT                    ((uint32_t)0x0569)   /* SDRAM refresh counter (90Mhz SD clock) */
#define SDRAM_TIMEOUT     ((uint32_t)0xFFFF)
/**
  * @brief  FMC SDRAM Mode definition register defines
  */
#define SDRAM_MODEREG_BURST_LENGTH_1             ((uint16_t)0x0000)
#define SDRAM_MODEREG_BURST_LENGTH_2             ((uint16_t)0x0001)
#define SDRAM_MODEREG_BURST_LENGTH_4             ((uint16_t)0x0002)
#define SDRAM_MODEREG_BURST_LENGTH_8             ((uint16_t)0x0004)
#define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL      ((uint16_t)0x0000)
#define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED     ((uint16_t)0x0008)
#define SDRAM_MODEREG_CAS_LATENCY_2              ((uint16_t)0x0020)
#define SDRAM_MODEREG_CAS_LATENCY_3              ((uint16_t)0x0030)
#define SDRAM_MODEREG_OPERATING_MODE_STANDARD    ((uint16_t)0x0000)
#define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) 
#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE     ((uint16_t)0x0200)
 
#define LCD_RST_HIGH	(GPIOB->BSRR |= GPIO_PIN_13)
#define LCD_RST_LOW		(GPIOB->BSRR |= (uint32_t)GPIO_PIN_13 << 16U)
#define LCD_CSX_HIGH	(GPIOB->BSRR |= GPIO_PIN_14)
#define LCD_CSX_LOW		(GPIOB->BSRR |= (uint32_t)GPIO_PIN_14 << 16U)
/* USER CODE END PD */
 
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
 
/* USER CODE END PM */
 
/* Private variables ---------------------------------------------------------*/
CRC_HandleTypeDef hcrc;
 
DMA2D_HandleTypeDef hdma2d;
 
I2C_HandleTypeDef hi2c1;
 
LTDC_HandleTypeDef hltdc;
 
USART_HandleTypeDef husart2;
 
NOR_HandleTypeDef hnor1;
SDRAM_HandleTypeDef hsdram1;
 
/* Definitions for TouchGFXTask */
osThreadId_t TouchGFXTaskHandle;
const osThreadAttr_t TouchGFXTask_attributes = {
  .name = "TouchGFXTask",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 2048
};
/* USER CODE BEGIN PV */
 
/* USER CODE END PV */
 
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_FMC_Init(void);
static void MX_CRC_Init(void);
static void MX_LTDC_Init(void);
static void MX_DMA2D_Init(void);
static void MX_I2C1_Init(void);
static void MX_USART2_Init(void);
void TouchGFX_Task(void *argument);
 
/* USER CODE BEGIN PFP */
static void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount);
static void LCD_init(void);
static void SPI_WriteComm(uint8_t data);
static void SPI_WriteData(uint8_t data);
static uint8_t Bit_Reversal(uint8_t v);
void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart);
/* USER CODE END PFP */
 
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
 
/* USER CODE END 0 */
 
/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */
  /* USER CODE END 1 */
 
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
    // LCD_init(); must be inserted before MX_TouchGFX_Init();
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_FMC_Init();
  MX_CRC_Init();
  MX_LTDC_Init();
  MX_DMA2D_Init();
  MX_I2C1_Init();
  MX_USART2_Init();
  LCD_init();
  MX_TouchGFX_Init();
  /* USER CODE BEGIN 2 */
 
  /* USER CODE END 2 */
  /* Init scheduler */
  osKernelInitialize();
 
  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */
 
  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */
 
  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */
 
  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */
 
  /* Create the thread(s) */
  /* creation of TouchGFXTask */
  TouchGFXTaskHandle = osThreadNew(TouchGFX_Task, NULL, &TouchGFXTask_attributes);
 
  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */
 
  /* Start scheduler */
  osKernelStart();
 
  /* We should never get here as control is now taken by the scheduler */
 
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}
 
static void MX_LTDC_Init(void)
{
 
  /* USER CODE BEGIN LTDC_Init 0 */
 
  /* USER CODE END LTDC_Init 0 */
 
  LTDC_LayerCfgTypeDef pLayerCfg = {0};
 
  /* USER CODE BEGIN LTDC_Init 1 */
 
  /* USER CODE END LTDC_Init 1 */
  hltdc.Instance = LTDC;
  hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
  hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
  hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
  hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
  hltdc.Init.HorizontalSync = 3;
  hltdc.Init.VerticalSync = 3;
  hltdc.Init.AccumulatedHBP = 7;
  hltdc.Init.AccumulatedVBP = 7;
  hltdc.Init.AccumulatedActiveW = 487;
  hltdc.Init.AccumulatedActiveH = 327;
  hltdc.Init.TotalWidth = 491;
  hltdc.Init.TotalHeigh = 331;
  hltdc.Init.Backcolor.Blue = 0;
  hltdc.Init.Backcolor.Green = 0;
  hltdc.Init.Backcolor.Red = 0;
  if (HAL_LTDC_Init(&hltdc) != HAL_OK)
  {
    Error_Handler();
  }
  pLayerCfg.WindowX0 = 0;
  pLayerCfg.WindowX1 = 480;
  pLayerCfg.WindowY0 = 0;
  pLayerCfg.WindowY1 = 320;
  pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB888;
  pLayerCfg.Alpha = 255;
  pLayerCfg.Alpha0 = 0;
  pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
  pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
  pLayerCfg.FBStartAdress = 0xC0000000;
  pLayerCfg.ImageWidth = 480;
  pLayerCfg.ImageHeight = 320;
  pLayerCfg.Backcolor.Blue = 0;
  pLayerCfg.Backcolor.Green = 0;
  pLayerCfg.Backcolor.Red = 0;
  if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN LTDC_Init 2 */
 
  /* USER CODE END LTDC_Init 2 */
}
 
/**
  * @brief USART2 Initialization Function
  * @param None
  * @retval None
  */
static void MX_USART2_Init(void)
{
 
  /* USER CODE BEGIN USART2_Init 0 */
 
  /* USER CODE END USART2_Init 0 */
 
  /* USER CODE BEGIN USART2_Init 1 */
 
  /* USER CODE END USART2_Init 1 */
  husart2.Instance = USART2;
  husart2.Init.BaudRate = 115200;
  husart2.Init.WordLength = USART_WORDLENGTH_9B;
  husart2.Init.StopBits = USART_STOPBITS_1;
  husart2.Init.Parity = USART_PARITY_NONE;
  husart2.Init.Mode = USART_MODE_TX;
  husart2.Init.CLKPolarity = USART_POLARITY_LOW;
  husart2.Init.CLKPhase = USART_PHASE_1EDGE;
  husart2.Init.CLKLastBit = USART_LASTBIT_ENABLE;
  if (HAL_USART_Init(&husart2) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART2_Init 2 */
 
  /* USER CODE END USART2_Init 2 */
 
}
uint8_t BSP_TS_Init(uint16_t xSize, uint16_t ySize)
    {
        uint8_t status = TS_OK;
        ts_x_boundary = xSize;
        ts_y_boundary = ySize;
 
        /* Read ID and verify if the IO expander is ready */
        if (stmpe811_ts_drv.ReadID(TS_I2C_ADDRESS) == STMPE811_ID)
        {
            /* Initialize the TS driver structure */
            ts_driver = &stmpe811_ts_drv;
            I2C_Address = TS_I2C_ADDRESS;
            ts_orientation = TS_SWAP_XY; //TS_SWAP_NONE; //TS_SWAP_Y;
        }
        else
        {
            IOE_Init();
 
            /* Check TS3510 touch screen driver presence to determine if TS3510 or
             * EXC7200 driver will be used */
            if (BSP_TS3510_IsDetected() == 0)
            {
                /* Initialize the TS driver structure */
                ts_driver = &ts3510_ts_drv;
                I2C_Address = TS3510_I2C_ADDRESS;
            }
            else
            {
                /* Initialize the TS driver structure */
                ts_driver = &exc7200_ts_drv;
                I2C_Address = EXC7200_I2C_ADDRESS;
            }
            ts_orientation = TS_SWAP_NONE;
        }
 
        /* Initialize the TS driver */
        ts_driver->Init(I2C_Address);
        ts_driver->Start(I2C_Address);
 
        return status;
    }

Martin KJELDSEN
Chief III

It's easier if you record a video of your issue - Did you debug the touch controller to also check that its behaving okay? Pressed, released, etc.

/Martin