cancel
Showing results for 
Search instead for 
Did you mean: 

Can the TSC be configured to support more than one active shield?

HCohe.1
Associate III

Our application has two touch sensors surrounded by a shield and an additional independent sensor surrounded by a separate shield. The first pair of sensors are connected to TSC groups 1 and 3. The other sensor uses groups 4 and 6. Groups 1 and 4 connect to the active shields. Unfortunately, CubeMX 6.3.0-RC5 does not allow more than one active shield to be selected. Is this due to a HW constraint (we're using the STM32WB5MMG) or a CubeMX error? If this configuration is supported by the TSC, what source code changes are required to work around CubeMX?

2 REPLIES 2
OlivierR
ST Employee

Hello,

We decide this to simplify TSC and TSL (TouchSensingLibrary) usages.

From TSC point of view, shield and sensor setting are the same, see TSC_Init() api for example:

/* Disable Schmitt trigger hysteresis on all used TSC IOs */
  htsc->Instance->IOHCR = (~(htsc->Init.ChannelIOs | htsc->Init.ShieldIOs | htsc->Init.SamplingIOs));
 
  /* Set channel and shield IOs */
  htsc->Instance->IOCCR = (htsc->Init.ChannelIOs | htsc->Init.ShieldIOs);

Except for groups:

/* Set the groups to be acquired */
  htsc->Instance->IOGCSR = TSC_extract_groups(htsc->Init.ChannelIOs);

On TSL side, this is more complex. We add a bank usage.

To move on, I will recommend you to do something like this

Let's assume:

  • Gx_IO1 are Sampling Capacitance
  • Gx_IO2/3/4 are sensors or active shield

  1. Create a Cube MX project
  2. Set G1_IO1 as samp cap
  3. Set G1_IO2 to Active Shield
  4. Set G3 and G6 to sensors
  5. Activate "TOUCHSENSING"
  6. Generate a project

Then code modification to add G4 as active shield will be something like:

  • Add G4 Active Shield to HAL_TSC_Init
Replace
  htsc.Init.ShieldIOs = TSC_GROUP1_IO2;
  htsc.Init.SamplingIOs = TSC_GROUP1_IO1|TSC_GROUP3_IO1|TSC_GROUP6_IO1;
By
  htsc.Init.ShieldIOs = TSC_GROUP1_IO2|TSC_GROUP4_IO2;
  htsc.Init.SamplingIOs = TSC_GROUP1_IO1|TSC_GROUP3_IO1|TSC_GROUP6_IO1|TSC_GROUP4_IO1;
  • Add AF GPIO for G4 (Sampling cap and shield) in HAL_TSC_MspInit
/**TSC GPIO Configuration
    ...
    PC6     ------> TSC_G4_IO1
    PC7     ------> TSC_G4_IO2
    ....
    */
   ....
    GPIO_InitStruct.Pin = GPIO_PIN_7;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF9_TSC;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 
    GPIO_InitStruct.Pin = GPIO_PIN_6;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF9_TSC;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  • Add G4 Active Shield to Banks (not group!)
Replace
/* Shield IOs definition */
#define SHIELD_IO_MSK      (TSC_GROUP1_IO2)
By
/* Shield IOs definition */
#define SHIELD_IO_MSK      (TSC_GROUP1_IO2|TSC_GROUP4_IO2)

This should work.

Regards. Olivier

HCohe.1
Associate III

It appears to be working well, Olivier. Thanks for your help.

Howard