cancel
Showing results for 
Search instead for 
Did you mean: 

How to change channel of TSC?

avinash_elec
Associate III

Hello Everyone!

I have thoroughly understood touch sense controller peripheral of STM32F051C8T6, I have also developed a test code using the HAL layer and is working file and detecting touch (i.e. is count value decreasing when finger comes near electrode). I have also read the TSC section of reference manual several times. I am unable to understand how to change the channel of acquisition within a group.

Right now what is happening is that I have enabled all three pins of IO group 2 as input electrode and the final (4th) one has the SAMPLING CAPACITOR connect to it. But the aquisition process always aquire the first channel only.

I am NOT able to find any function in HAL lib to change channel NOR I am able to find any register that controls that.

Some where it is written that acquisition within a group is sequential, but it is NOT also happening, each time only channel 1 is acquired.

TscHandle.Instance                     = TSC;
	TscHandle.Init.AcquisitionMode         = TSC_ACQ_MODE_NORMAL;
	TscHandle.Init.CTPulseHighLength       = TSC_CTPH_2CYCLES;
	TscHandle.Init.CTPulseLowLength        = TSC_CTPL_2CYCLES;
	TscHandle.Init.IODefaultMode           = TSC_IODEF_OUT_PP_LOW;
	TscHandle.Init.MaxCountInterrupt       = DISABLE;
	TscHandle.Init.MaxCountValue           = TSC_MCV_16383;
	TscHandle.Init.PulseGeneratorPrescaler = TSC_PG_PRESC_DIV16;
	TscHandle.Init.SpreadSpectrum          = DISABLE;
	TscHandle.Init.SpreadSpectrumDeviation = 127;
	TscHandle.Init.SpreadSpectrumPrescaler = TSC_SS_PRESC_DIV1;
	TscHandle.Init.SynchroPinPolarity      = TSC_SYNC_POLARITY_FALLING;
	TscHandle.Init.ChannelIOs              =TSC_GROUP2_IO1|TSC_GROUP2_IO2|TSC_GROUP2_IO3;
	TscHandle.Init.SamplingIOs             = TSC_GROUP2_IO4;
	TscHandle.Init.ShieldIOs               = 0;
 
	HAL_TSC_Init(&TscHandle);

1 REPLY 1
Piranha
Chief II
TscHandle.Init.ChannelIOs              =TSC_GROUP2_IO1|TSC_GROUP2_IO2|TSC_GROUP2_IO3;

You cannot do that, because HAL doesn't provide any automation. You still have to call HAL_TSC_IODischarge() and switch pins with HAL_TSC_IOConfig() manually. That's the essence of HAL - it is marketed as high-level abstraction, but in reality almost everything still has to be done manually. The only value that junk provides is an incredible amount of bugs and filling of flash and RAM memories with useless bloat.

P.S. Why did you created a duplicate topic?