2025-09-23 5:53 AM
Hi,
I'm configuring the CubeMX for an application with 5 capacitive sensors.
I used G1_IO1 and G1_IO2 for two sensors, and G1_IO3 for the sampling capacitor of G1. The other three sensors are on G4_IO1, G4_IO2 and G4_IO3, with the sampling capacitor on G4_IO4.
The active shield is configured on G3_IO2 with the sampling cap on G3_IO3.
I would like to define banks to sample G1_IO1 at the same time as G4_IO1 (and shield), and G1_IO2 with G4_IO2 (and shield). The third bank will be a single channel (G4_IO3).
I was actually able to set it in the tsl_user.h as
#define CHANNEL_0_IO_MSK (TSC_GROUP1_IO1)
#define CHANNEL_0_GRP_MSK (TSC_GROUP1)
#define CHANNEL_0_SRC (TSC_GROUP1_IDX) /* Index in source register (TSC->IOGXCR[]) */
#define CHANNEL_0_DEST (0) /* Index in destination result array */
#define CHANNEL_1_IO_MSK (TSC_GROUP1_IO2)
#define CHANNEL_1_GRP_MSK (TSC_GROUP1)
#define CHANNEL_1_SRC (TSC_GROUP1_IDX)
#define CHANNEL_1_DEST (1)
#define CHANNEL_2_IO_MSK (TSC_GROUP4_IO1)
#define CHANNEL_2_GRP_MSK (TSC_GROUP4)
#define CHANNEL_2_SRC (TSC_GROUP4_IDX)
#define CHANNEL_2_DEST (2)
#define CHANNEL_3_IO_MSK (TSC_GROUP4_IO2)
#define CHANNEL_3_GRP_MSK (TSC_GROUP4)
#define CHANNEL_3_SRC (TSC_GROUP4_IDX)
#define CHANNEL_3_DEST (3)
#define CHANNEL_4_IO_MSK (TSC_GROUP4_IO3)
#define CHANNEL_4_GRP_MSK (TSC_GROUP4)
#define CHANNEL_4_SRC (TSC_GROUP4_IDX)
#define CHANNEL_4_DEST (4)
#define BANK_0_NBCHANNELS (1)
#define BANK_0_MSK_CHANNELS (CHANNEL_0_IO_MSK | CHANNEL_2_IO_MSK | SHIELD_IO_MSK)
#define BANK_0_MSK_GROUPS (CHANNEL_0_GRP_MSK | CHANNEL_2_GRP_MSK)
#define BANK_1_NBCHANNELS (2)
#define BANK_1_MSK_CHANNELS (CHANNEL_1_IO_MSK | CHANNEL_3_IO_MSK | SHIELD_IO_MSK)
#define BANK_1_MSK_GROUPS (CHANNEL_1_GRP_MSK | CHANNEL_3_GRP_MSK)
#define BANK_2_NBCHANNELS (1)
#define BANK_2_MSK_CHANNELS (CHANNEL_4_IO_MSK | SHIELD_IO_MSK)
#define BANK_2_MSK_GROUPS (CHANNEL_4_GRP_MSK)
But the code is not between
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
so I suppose that every time I generate code from CubeMX I will have to do the same configuration again.
Is there a way to set these banks in CubeMX directly and let it generate the code?
Thank you.
2025-09-23 6:22 AM
Hello @mstighi
You are correct that code placed outside the /* USER CODE BEGIN ... */ and /* USER CODE END ... */ blocks in tsl_user.h will be overwritten each time you regenerate code with CubeMX.
Could you please share your .ioc file so I can review your configuration and assist you further?
BR,
Ghofrane
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-09-23 6:29 AM