2016-08-30 02:56 AM
Hi,
I'm trying to figure out, how to use the CubeMX generated project for touch sense aplication. I'm able to detect the change on the 3 touch buttons, but i can't figure out, how to detect on which touch button did the change arrived.The code:static void MX_TSC_Init(void){ /**Configure the TSC peripheral */ htsc.Instance = TSC; htsc.Init.CTPulseHighLength = TSC_CTPH_2CYCLES; htsc.Init.CTPulseLowLength = TSC_CTPL_2CYCLES; htsc.Init.SpreadSpectrum = DISABLE; htsc.Init.SpreadSpectrumDeviation = 0; htsc.Init.SpreadSpectrumPrescaler = TSC_SS_PRESC_DIV1; htsc.Init.PulseGeneratorPrescaler = TSC_PG_PRESC_DIV64; htsc.Init.MaxCountValue = TSC_MCV_255; htsc.Init.IODefaultMode = TSC_IODEF_OUT_PP_LOW; htsc.Init.SynchroPinPolarity = TSC_SYNC_POLARITY_FALLING; htsc.Init.AcquisitionMode = TSC_ACQ_MODE_NORMAL; htsc.Init.ChannelIOs = TSC_GROUP2_IO1|TSC_GROUP2_IO2|TSC_GROUP2_IO3; htsc.Init.SamplingIOs = TSC_GROUP2_IO4; if (HAL_TSC_Init(&htsc) != HAL_OK) { Error_Handler(); }}//mainHAL_TSC_IODischarge(&htsc, ENABLE); if (HAL_TSC_Start(&htsc) != HAL_OK) { Error_Handler(); }while (1) { if (HAL_TSC_Start(&htsc) != HAL_OK) { Error_Handler(); } while (HAL_TSC_GetState(&htsc) == HAL_TSC_STATE_BUSY) {} __HAL_TSC_CLEAR_FLAG(&htsc, (TSC_FLAG_EOA | TSC_FLAG_MCE));if (HAL_TSC_GroupGetStatus(&htsc, TSC_GROUP2_IDX) == TSC_GROUP_COMPLETED) { // Store the acquisition value uhTSCAcquisitionValue = HAL_TSC_GroupGetValue(&htsc, TSC_GROUP2_IDX); } HAL_TSC_IODischarge(&htsc, ENABLE);}Thanks for any help.2016-08-30 06:28 AM
Hi,
I recommended you to start from the TouchSensing application under the STM32CubeL4 package:STM32Cube_FW_L4_V1.5.0\Projects\STM32L476G_EVAL\Applications\TouchSensingYou can get inspiration from this example and compare with your code to identify what you have missed.Please note that you may find more details on how to use the TSL with this manual
''Developing applications on STM32Cube with touch sensing''.and .Regards2016-09-01 03:15 AM
Hi,
I have already looked at the example, but i got lost in the code. That's the reason I wrote to the forum. As I mentioned i can detect the change of the acquisition value for the group, but i would like to know if there is an easy way to detect on which IO (TSC_GROUP2_IO1, TSC_GROUP2_IO2, TSC_GROUP2_IO3) of the group is responsible for the change.2016-09-02 03:39 AM
Hi,
i have looked at the . The reference circuit that i used is shown on the 6-th picture. The STM32L4 Eval is using only 1 touch key. So i have looked at the examples for other eval boards. They all use 1 sampling capacitor for each channel, so they also don't tell me the method.2017-09-24 04:20 AM
Hi,
I want to ask you on which board are you working?
I want to build a capacitive touch sensor on a Nucleo-64 board, I used the same reference circuit that you have used and I wrote a code but it did not work. I have tried tried to use your code, it did not work either. I am not able to detect any change on any touch buttons! if you have any helpful hint, I will appreciate it.
Thank you.