cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure multiple sensors in STM32CubeMX and TrueStudio

ndsmith34
Associate II

I have an STM32F0DSCOVERY and I have successfully configured it with CubeMX and TrueStudio to read a single touch input. I can read out the data in STM Studio and it graphs the measurement and the delta and the StateId and everything is beautiful. However, when I try to add a second touch input the second input always reads as zero while the first continues to work.

In my working configuration (with one input) I have G6_IO3 (PB13) configured as my first basic touchkey (IO_TOUCHKEY_B1) and G6_IO1 (PB11 with sampling capacitor attached) configured as the sampling input. In main() I run the following code:

/* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
	  status = tsl_user_Exec();
	  TSL_tkey_Process();
  }
  /* USER CODE END 3 */

This works fine and I'm happy with it as long as I'm only looking at one input.

To add my second input, in CubeMX, I configure G6_IO4 (PB14) as my second basic touchkey (IO_TOUCHKEY_B2) and increase my total basic touchkeys to 2 in the TOUCHSENSING middleware.

When I run the code that it generates it still reads the first input fine, but does not read the second input. I can even change the order of the inputs (make IO_TOUCHKEY_B1 = G6_IO4 and IO_TOUCHKEY_B2 = G6_IO3) and it will switch which input it reads, but still only reads one input. Whatever IO_TOUCHKEY_B1 is set to it always reads that input fine.

When I have two inputs, I notice the code generates two banks and puts one channel in each bank. How can I put both channels (both inputs) in one bank (I'm not sure if I'm using the terms "channel" and "bank" properly)?

Stepping through the code it appears to attempt to read both banks, but the second input is always read as zero. How can I enable the second input?

0 REPLIES 0