AnsweredAssumed Answered

Touchscreen setting on custom board (STM32F7 MCU)

Question asked by enia ami on 17-Feb-2017
Latest reply on 21-Feb-2017 by enia ami


I have a custom board based on the STM32F769IBIT MCU. I want to implement a BSP layer as there are with ST discovery boards. 
I've already implemented the SDRAM, the flash and the LCD (densitron 84-0226-000T) but I'm struggling with the touchscreen which is the same one as mounted on the stm32f746g disco (ft5336 Focaltech).
But I get an error for the TS whereas I'm using the ST init sequence. It seems to be that the TS is not detected or does not "respond". 
Here is the sequence I use to init the TS and where I've found the error :
#define TS_I2C_ADDRESS                   ((uint16_t)0x70)
uint16_t TS_Init(uint16_t ts_SizeX, uint16_t ts_SizeY)
// variables init
/* Read ID and verify if the touch screen driver is ready */
  ft5336_ts_drv.Init(TS_I2C_ADDRESS); // no error returned , see the init strucs below
  if(ft5336_ts_drv.ReadID(TS_I2C_ADDRESS) == FT5336_ID_VALUE)
     // instructions
    status = TS_OK; 
     status = TS_DEVICE_NOT_FOUND; //the returned error
  return status; //TS_DEVICE_NOT_FOUND is returned
When I dig for the function that returns the error, I found this one :
HAL_StatusTypeDef I2C_WaitOnTXISFlagUntilTimeout(I2C_HandleTypeDef *hi2c, uint32_t Timeout, uint32_t Tickstart)
and more prcisely, inside of it :
/* Check if a NACK is detected */
if(I2C_IsAcknowledgeFailed(hi2c, Timeout, Tickstart) != HAL_OK)
      return HAL_ERROR;
It seems that a NACK (Not ACKnowledge) flag is detected. 
The init seq (called by ft5336_ts_drv.Init(TS_I2C_ADDRESS)) :
i2c_handler->Instance              = I2C2;
i2c_handler->Init.Timing           = (uint32_t)0x40912732;
i2c_handler->Init.OwnAddress1      = 0;
i2c_handler->Init.AddressingMode   = I2C_ADDRESSINGMODE_7BIT;
i2c_handler->Init.DualAddressMode  = I2C_DUALADDRESS_DISABLE;
i2c_handler->Init.OwnAddress2      = 0;
i2c_handler->Init.GeneralCallMode  = I2C_GENERALCALL_DISABLE;
i2c_handler->Init.NoStretchMode    = I2C_NOSTRETCH_DISABLE;
/* Configure I2C Tx as alternate function */
gpio_init_structure.Pin = GPIO_PIN_10;
gpio_init_structure.Mode = GPIO_MODE_AF_OD;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_FAST;
gpio_init_structure.Alternate = GPIO_AF4_I2C2;
HAL_GPIO_Init(GPIOB, &gpio_init_structure);
/* Configure I2C Rx as alternate function */
gpio_init_structure.Pin = GPIO_PIN_11;
HAL_GPIO_Init(GPIOB, &gpio_init_structure);
/*** Configure the I2C peripheral ***/
/* Enable I2C clock */
/* Force the I2C peripheral clock reset */
/* Release the I2C peripheral clock reset */
As you cas see, at this point the INT pin is not configured. 
Also, I don't know what should be the behaviour of the RST as there is no mention of it in the ST code.
If you have any suggestion, it would be much appreciated.
thank you.