2021-09-09 06:16 AM
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?
2021-09-10 06:32 AM
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:
Then code modification to add G4 as active shield will be something like:
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;
/**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);
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
2021-09-27 11:39 AM
It appears to be working well, Olivier. Thanks for your help.
Howard