10 years, 4 months ago.

Values for ELEC0 and ELEC1 - connecting different electrodes?

How would I sense capacitive touch on my own, off-board electrodes connected to two pins? I'm not sure what the values 9 and 10 for ELEC0 and ELEC1 in the example refer to.

Using PinNames doesn't seem to work - I tried PinNames TSI_ELEC0, TSI_ELEC1 (defined in PinNames.h for the KL25Z), but this breaks the example code.

Question relating to:

The TSI Analog slider demo for the freedom platform with Kinetis L MCU. FRDM, Freedom, sensing, touch, TSI

Have you found a solution to use the different available channels?

posted by John Miller 16 Sep 2016

2 Answers

10 years, 4 months ago.

Hello Bjoern Hartmann,

yes, the TSI library uses TSI peripheral channels, not PinNames as you noticed. You can implement a proper mapping of PinName - TSI channel and send a pull request to TSI library.

Regards,
0xc0170

Accepted Answer
10 years, 4 months ago.

According to the schematic it is PTB16 and PTB17. http://mbed.org/platforms/KL25Z/#technical-reference

TSI_ELEC0 and TSI_ELEC1 are aliases for PTB16 and PTB17 - their values (in PinNames.h) are:

  • PTB16 = 0x1040,
  • PTB17 = 0x1044,
  • TSI_ELEC0 = PTB16,
  • TSI_ELEC1 = PTB17

Using these constants in the FRDM TSI code template does *not* work. Instead, the code needs "magic" values 9 and 10.

My question was where these magic values come from and how I'd find other values to connect sliders to other pins.

I may have found the answer on page 44 of the KL25 datasheet (http://cache.freescale.com/files/32bit/doc/data_sheet/KL25P80M48SF0.pdf) It lists the default pin function for PTB16 as "TSIO_CH9" and PTB17 as "TSIO_CH10"

So apparently the TSI library wants channel IDs instead of pin names.

Here's my summary of pin name to channel mapping:

  • PTA0 - TSI0_CH1
  • PTA1 - TSI0_CH2
  • PTA2 - TSI0_CH3
  • PTA3 - TSI0_CH4
  • PTA4 - TSI0_CH5
  • PTB0 - TSI0_CH0
  • PTB1 - TSI0_CH6
  • PTB2 - TSI0_CH7
  • PTB3 - TSI0_CH8
  • PTB16 - TSI0_CH9
  • PTB17 - TSI0_CH10
  • PTB18 - TSI0_CH11
  • PTB19 - TSI0_CH12
  • PTC0 - TSI0_CH13
  • PTC1 - TSI0_CH14
  • PTC2 - TSI0_CH15
posted by Bjoern Hartmann 03 Aug 2014