cancel
Showing results for 
Search instead for 
Did you mean: 

STM32l052R6 Touch-Lib (HAL_TSC) with CubeMX

oliver239955
Associate II
Posted on June 12, 2015 at 14:58

Hi guys,

I got problems including some TouchPads with the ''transfer acquisition principle'' with a STM32L052R6 and the CubeMX-generated HAL_TSC library.

I couldn't find an example code or a evaluation board, from which I can get the sequence read out a touch-channel and see if it detected a finger or not.

Would be great if anybody who knows like it works would help me a bit.

Thanks an have a nice weekend

Edit:

Tried something like this yet:

        tscioconfig.ChannelIOs |= TSC_GROUP6_IO1 | TSC_GROUP8_IO4 ;

        tscioconfig.SamplingIOs |= TSC_GROUP6_IO4 | TSC_GROUP8_IO3;

        tscioconfig.ShieldIOs |= TSC_GROUP1_IO2;

        HAL_TSC_IOConfig(&htsc, &tscioconfig);      

        

        // Discharge

        HAL_TSC_IODischarge(&htsc, DISABLE);

        HAL_Delay(1);

        

        HAL_TSC_Start(&htsc);

        

        HAL_TSC_PollForAcquisition(&htsc); // HAL_TSC_GetState();

        

        ui32_calc1 = HAL_TSC_GroupGetStatus(&htsc, TSC_GROUP6);

        ui32_calc1 = HAL_TSC_GroupGetStatus(&htsc, TSC_GROUP8);

        ui32_calc2 = HAL_TSC_GroupGetValue(&htsc, TSC_GROUP6);

        ui32_calc2 = HAL_TSC_GroupGetValue(&htsc, TSC_GROUP8);

        

        HAL_TSC_Stop(&htsc);

#stm32l0-touch-hal-tsc-cubemx
9 REPLIES 9
nesrine
Senior
Posted on June 15, 2015 at 11:17

Hello Olivjer,

1-you need at first to configure the TSC peripheral 

2- Configure the touch-sensing IOs:

  IoConfig.ChannelIOs  = TSC_GROUP6_IO2; 

  IoConfig.SamplingIOs = (TSC_GROUP6_IO3 | TSC_GROUP3_IO3 | TSC_GROUP1_IO3 | TSC_GROUP8_IO2);

  IoConfig.ShieldIOs   = TSC_GROUP8_IO1;

3- Discharge the touch-sensing IOs

  HAL_TSC_IODischarge(&TscHandle, ENABLE);

  HAL_Delay(1); 

4- Start the acquisition process 

    if (HAL_TSC_Start(&TscHandle) != HAL_OK)

    {

      Error_Handler();

    }

5- Wait for the end of acquisition

   while (HAL_TSC_GetState(&TscHandle) == HAL_TSC_STATE_BUSY)

    {

    }

6- Clear flags

  __HAL_TSC_CLEAR_FLAG(&TscHandle, (TSC_FLAG_EOA | TSC_FLAG_MCE));

7- Check if the acquisition is correct:   

 if (HAL_TSC_GroupGetStatus(&TscHandle, TSC_GROUP6_IDX) == TSC_GROUP_COMPLETED)

    {

8- Store the acquisition value 

      uhTSCAcquisitionValue = HAL_TSC_GroupGetValue(&TscHandle, TSC_GROUP6_IDX);

}

I hope that help

Syrine

oliver239955
Associate II
Posted on June 15, 2015 at 16:09

Good afternoon syrine,

Thanks a lot for your help, that helped me enormous understanding the whole handling of the HAL_TSC lib.

I've implemented the process into my code but I always get a 1 back after the command ''HAL_TSC_GroupGetValue(&TscHandle, TSC_GROUP6_IDX);'' so I maybe made a mistake with the hardware.

May I ask you, what value your ESD-Resistors (serial in the path from TouchPad to Microprocessor-Input) and what value your Sampling-Capacitors (Shield and Groups) are?

ESD-Resistors:     2.7 kOhm

Group-Sampling:  100 pF

Shield-Sampling:  100 pF

Maybe I should go higher with the values of the capacitors to charge them better?

Thank you again for your help, appreciate it very much!

Olivjer

l239955_stm1
Associate II
Posted on June 17, 2015 at 07:43

Hi,

you can look at stm32l discovery board, there are used capacitors 47nF a resistors 10k. Now I´m developing control touch panel with stm32l053. I tried more values of capacitors and it always works (only change of touch response)

oliver239955
Associate II
Posted on June 22, 2015 at 17:00

You were right, I've found the values in the Eval-Board. Thanks for that!

You said you tried a lot of combinations. With what combinations you had the best results in distance between finger and touchpad?

In my case it works only, if the finger really touchs the Touchfield, but in my opinion it should also work with a little gap of 1-2mm, or not?

l239955_stm1
Associate II
Posted on June 23, 2015 at 07:55

Look at the application notes ''Guidelines for designing touch sensing applications'' (http://www.st.com/web/en/resource/technical/document/application_note/CD00222015.pdf) there is described how to design touch sensing app. I think to high sensitivity sensor is important size of electrode surface:  larger electrode -> higher capacity -> higher sensitivity

oliver239955
Associate II
Posted on June 23, 2015 at 10:39

Thanks a lot. I already did this, it does not decribe what to do when you have a low sensivity. Tried also a lot of diferent values for the capacitors.

As I understand the Touchfield should only be as large as the thing you touch it with, otherwise the parasitic capacitance increases.

Ricky S
Associate II
Posted on September 22, 2017 at 09:29

what is the shield samping used for ? is it nessary?

Posted on September 25, 2017 at 11:33

does the sensor work with you without shielding?

Posted on September 27, 2017 at 04:16

I got a project generated by CubeMX, without shieldIO setting, and I haven't make it run. Is there a exampling project for STM32F051?