Configuring and Using K20 TSI with TSS_Library Component in a MQX application

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Configuring and Using K20 TSI with TSS_Library Component in a MQX application

Jump to solution
2,217 Views
Vagni
Contributor IV

I started developing my first Touch Sensing application on my Kinetis K20DX256VLH7-based custom board. I use CodeWarrior 10.2 (full updated), MQX 3.8.1 and TSS v2.6. I added the TSS_Library component to the Processor Expert project used in my BSP library (which I cloned from the bsp_twrk20dx72 sample library).

On my custom board I have six electrodes and I handle them as a TSS Keypad Control through the K20 TSI module.

I configured the TSS_Library component with standard settings, in order to tune them through the FreeMASTER tool on my PC communicating with the RS485 port on my board (I use a USB-RS485 cable from FTDI).

After many efforts, I finally have a compiled BSP and a MQX compiled application with the Main_task that initializes both FreeMASTER resources and TSS and then waits for a touch/release event from the keypad.

 

But unfortunately I get no such event when my application is running. Where am I wrong?

 

I configured TSI with AUTO trigger mode with Auto_Trigger_Modulo_Value = 255. With the debugger I verified the TSI registers: the six electrode inputs are properly defined and enabled; the TSI module is enabled, the TSI interrupt is enabled. TSI clock is the bus-clock (48 MHz) with prescaler = 1.

With my scope on each electrode I see the external frequency signal generated by TSI: when I change the electrode capacitance with my finger I see the frequency become a little bit slower.

But I don't understand why TSI scans my keypad every 250ms. Which TSI register configures that time?

 

On the FreeMASTER tool I have the communication properly running. The TSS System and Keypad Control configuration are as I expected, but all the Baseline, Delta and Signal variables are equal to 0.

 

I attach my BSP Processor Expert project, the produced TSS_SystemSetup.h header file, my application Main_task source code and my FreeMASTER GUI project.

 

Can anyone help me to have TSI working properly?

 

Best Regards

Original Attachment has been moved to: ProcessorExpert.pe.zip

Original Attachment has been moved to: UG8_GUI.pmp.zip

Original Attachment has been moved to: main.c.zip

Original Attachment has been moved to: TSS_SystemSetup.h.zip

Labels (1)
0 Kudos
1 Solution
926 Views
moravcik
Contributor III

Hi Alessandro,

Your analysis about AUTO trigger mode is right so far and here are my comments. Everything is written also in the TSSAPIRM. The TSI measurement period in AUTO trigger mode equals to Auto Trigger Source Period. If the TSI is selected as Auto Trigger Source then this period is defined as: AutoTriggerSourcePeriod = (1 / ((TSI_AMCLKSclk / TSI_AMPSC) / TSI_AMCLKDIV)) * SMOD. All parameters are set in the TSS_SystemSetup.h except SMOD which is set by AUTO Trigger Period Register in TSS structures.

Small AUTO Trigger Period fault indicates that TSS_Task() call period (time between two TSS_Task() == TSS_STATUS_OK) is longer than AUTO trigger period. There is also small overhead time caused by internal processing of TSS_Task(). If this fault is reported then TSI data can be lost, because TSI data are read during the TSS_Task() only. This fault is also reported if all electrodes are not measured yet and the next TSI measurement is started by the trigger. The time of TSI measurement also depends on NSCN, number of enabled electrodes (PEN) and External (electrode) oscillator setup.

I really recommend to use ALWAYS mode in the MQX, because there are longer periods between TSS_Task() calls. The AUTO trigger and SW trigger can be helpful if precise synchronization is needed, for example zero-cross synchronization with mains etc.

Best Regards

Peter Moravcik

TSS SW Team


View solution in original post

0 Kudos
8 Replies
926 Views
Vagni
Contributor IV

I found a "Small Trigger Period" fault occurs after my TSS system initialization. And this fault causes my TSS system to be disabled. Is this why I see all the Baseline, Delta and Signal variables equal to 0 and the touch/release events never occur?

If I clear the fault flag and re-enable the TSS system, a new "Small Trigger Period" fault occurs.
On the TSS API Reference Manual I see this fault could be caused in AUTO trigger mode by not calling TSS_Task() as often as possible. In my system I see with my scope that the Auto_Trigger_Modulo_Value (SMOD) set the trigger period in milliseconds, but I don't understand how. With Auto_Trigger_Modulo_Value = 25 I get a trigger period of 25ms and I call TSS_Task() in my application Main_task every 5ms: is it not enough?

What is the relationship between Active Mode Clock Source (AMCLKCS), Active Mode Clock Prescaler (AMPSC), Active Mode Clock Modulo (SMOD) and trigger period in AUTO trigger mode?

Furthermore, the Kinetis K20-72MHz TSI has got some errata for the current chip mask 1N36B: does TSS Library execute the suggested workarounds (e.g. e2638 errata on the End-Of-Scan interrupt) ?

0 Kudos
926 Views
Vagni
Contributor IV

I found more ...

  1. Setting "Bus clock" as Active Mode Clock Source (AMCLKCS) in the TSS_Library Component for a K20 device sets the LPOSCCLK (1kHz) as clock source, instead. This is why the Active Mode Clock Modulo (SMOD) value sets the trigger period in milliseconds in AUTO trigger mode.
  2. Setting the Sample Number (NSCN) to 8, I expect TSI performs up to 8 scans on each electrode for every trigger. But instead I see TSI in AUTO trigger mode performs as many scan cycles as can be made in a single prescaled clock source period (1ms, 2ms, 4ms, ..., 128ms). Why?
  3. With the same clock source (LPOSCCLK, 1kHz) I set ALWAYS trigger mode: a single scan for each electrode is now performed every 10ms and finally with this trigger mode I get no errors, my TSS1_fCallBack0() is called upon an event on the keypad control and I can see the touch Signal and Delta variables on the FreeMASTER tool window changing if I press the keypad with my finger. Who fix the trigger period to 10ms?

It looks like K20 TSI doesn't work properly in AUTO trigger mode ...

0 Kudos
926 Views
Vagni
Contributor IV

More info data ...

  1. In ALWAYS trigger mode I see the time between scans depends upon how often the TSS_Task() is called: if it is called every 5ms, I see one scan every 10ms; if it is called continuously, I see one scan every 680us (on my board I have a keypad with 6 touch keys).
  2. With 50ms AUTO trigger period (SMOD=50), NSCN=8 and TSS Response Time = 4 I get no errors if I call TSS_Task() continuously. Even if I call TSS_Task() every 1ms I get  "Small Trigger Period" fault.

So, I still don't understand how to calculate the maximum time interval for calling TSS_Task() from a prefixed values for AUTO trigger period, NSCN and Response time to get no errors.

I need this time interval value, because I am developing a MQX-based application and TSS_Task() is called by one of my tasks: I cannot call TSS_Task() continuously.

0 Kudos
927 Views
moravcik
Contributor III

Hi Alessandro,

Your analysis about AUTO trigger mode is right so far and here are my comments. Everything is written also in the TSSAPIRM. The TSI measurement period in AUTO trigger mode equals to Auto Trigger Source Period. If the TSI is selected as Auto Trigger Source then this period is defined as: AutoTriggerSourcePeriod = (1 / ((TSI_AMCLKSclk / TSI_AMPSC) / TSI_AMCLKDIV)) * SMOD. All parameters are set in the TSS_SystemSetup.h except SMOD which is set by AUTO Trigger Period Register in TSS structures.

Small AUTO Trigger Period fault indicates that TSS_Task() call period (time between two TSS_Task() == TSS_STATUS_OK) is longer than AUTO trigger period. There is also small overhead time caused by internal processing of TSS_Task(). If this fault is reported then TSI data can be lost, because TSI data are read during the TSS_Task() only. This fault is also reported if all electrodes are not measured yet and the next TSI measurement is started by the trigger. The time of TSI measurement also depends on NSCN, number of enabled electrodes (PEN) and External (electrode) oscillator setup.

I really recommend to use ALWAYS mode in the MQX, because there are longer periods between TSS_Task() calls. The AUTO trigger and SW trigger can be helpful if precise synchronization is needed, for example zero-cross synchronization with mains etc.

Best Regards

Peter Moravcik

TSS SW Team


0 Kudos
926 Views
Vagni
Contributor IV

Hi Peter,

I come back to this thread, because I need more informations regarding to the TSS Library configuration.

Till now I configure the TSS at startup and then I properly get the "touched" or "released" events from the TSS Library on my six electrodes keypad.

Now my board is under EMC tests and I see that some false touch events are detected when conducted noise is applied to my board.

In order to make my system more robust against noise I could do the followings:

  • enable IIR filter;
  • enable shielding function;
  • increase the sensitivity threshold;
  • change Sample Number (NSCN);
  • change external current setting (EXTCHRG);
  • change prescaler setting (PS).

The sensitivity threshold can be configured run-time at startup, while all the other parameters can be configured only in compile-time with the TSS_SystemSetup.h header file.

Because of my board can be programmed only through the JTAG interface and I need to change those parameters while the test is running, how can I achieve this?

Surely, I need to change some of the TSS Library configuration source files, like TSS_SensorTSI.c and TSS_SystemSetupData.c ... If I could do it, is the following procedure correct to change the TSS Library configuration in run-time?

  1. write to the System Configuration register for disable the system;
  2. change one or more parameters;
  3. write to the System Configuration register for re-enable the system and start a hardware recalibration.

What is the difference between hardware recalibration and manual recalibration?

What is the effect of a system reset command?

Is it possible to change some of those parameters with the FreeMASTER tool? and how?

Best Regards,

Alessandro

0 Kudos
926 Views
moravcik
Contributor III

Hi Alessandro,

You cannot change parameters configured in TSS_SystemSetup.h, like enable IIR filter and shielding function. Also

TSI External current setting (EXTCHRG) and prescaler setting (PS) are defined in TSS_SystemSetup.h by defines  TSS_TSI_EXTCHRG_LOW_LIMIT / HIGH_LIMIT and TSS_TSI_PS_LOW_LIMIT / HIGH_LIMIT. This configuration is static, so cannot be changed in runtime. You have to recompile whole project. For noise immunity is recommended to use higher value of EXTCHRG.

You can change in runtime just registers of TSS. So the following your parameters can be configured:

  • Sensitivity threshold; - register System_Sensitivity_Register in TSS
  • Sample Number (NSCN); - register System_NSamples_Register in TSS

I think that against noise can help also following settings:

  • Dc-tracker configuration - DC Tracker Rate register in TSS - shorter period will adapt baseline to signal faster
  • Debouncing configuration - Response Time register in TSS - longer response time will do more reliable recognition of touch

You can also modify IIR filter equation TSS_IIRFilterEquation() in TSS_SystemSetupData.c file. The higher weight of the filtration can help.

You can change all registers without disabling of TSS, but it is recommended to do it after the moment if TSS_Task() returns TSS_STATUS_OK. Only if you want to change Sensitivity threshold then whole TSS reinitialization should be done. This can be done by the SystemReset bit in TSS registers or by the TSS_Init() call and then you have to initialize all registers again. It is mainly recommended if automatic sensitivity calibration is enabled.

Manual recalibration starts only update of baseline by dc-tracker. HW recalibration starts recalibration of whole low level e.g. TSI module recalibration, but it is done only if all module electrodes are released.

SystemReset performs the same like TSS_Init() call.

The FreeMASTER can change just TSS runtime registers. The FreeMASTER GUI contains nice html interface which can edit all TSS registers. The FreeMASTER GUI is doing changes only in the phase where TSS_Task() == TSS_STATUS_OK.

Best Regards

Peter Moravcik

TSS SW Team

0 Kudos
926 Views
Vagni
Contributor IV

Just now I see that the TWR-K60N512 BSP library (bsp_twrk60n512) provides a HMI layer based on TSS Library. The HMI layer handles touch sensing board buttons with K60 TSI peripheral, push buttons and leds.

It should be no coincidence that HMI layer configures TSS Library with the following parameters:

  • Trigger mode: ALWAYS
  • Number of Samples: 8
  • Sensitivity values for all the electrodes: 64

leaving all the rest to the default values.

The TSS polling function is executed every 25ms with the following code:

     while (TSS_Task() != TSS_STATUS_OK);

I think that is the only TSS Library configuration set to use TSI in a MQX application.

0 Kudos
926 Views
moravcik
Contributor III

Hi Alessandro,

You are right, some of the MQX bsp's provide also HMI layer which contains TSS files inside. Here is the list of bsp's with HMI layer: kwikstikk40x256, twrk40x256, twrk53n512, twrk60n512, twrk70f120m, twrmcf51jf, twrmcf51qm.

If bsp contains HMI and TSS Component is used with installation of TSS files, there can be conflict between these TSS files. The user should use HMI files in this case, or eventually modify the HMI layer with the TSS component configuration.

Best Regards

Peter Moravcik

TSS SW Team