Using K20 TSI Peripheral

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

Using K20 TSI Peripheral

943 Views
Vagni
Contributor IV

I am trying to handle with the TSI peripheral a touch sense keypad on my custom K20DX256VLH7-based board with the Processor Expert TSS_Library component v2.6.

I use TSI only in active mode. The Bus-clock on my board is set at 48MHz and I chose this clock as TSI active mode source clock.

Also, I chose to use the AUTO trigger mode for TSI.

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?

I have this question, because from the K20 Reference Manual I don't understand how to get the trigger period from those register and in my system I get always a "Small Trigger Period" fault output by the TSS Library.

With my scope I see in my system that SMOD value set the trigger period in milliseconds: why?

If I set SMOD=25, trigger period is 25ms; if I set SMOD=255, trigger period is 255ms. I call TSS_Task() every 5ms, but in both case I get the "Small Trigger Period" fault.

Furthermore, the Kinetis K20-72MHz TSI has got some errata for the current chip mask 1N36B: does Processor Expert TSS_Library component v2.6 consider them (e.g. e2638 errata on the End-Of-Scan interrupt) ? Or is it up to my code ?

Labels (1)
Tags (1)
0 Kudos
3 Replies

451 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

451 Views
eduardo_viramon
NXP Employee
NXP Employee

Hi Alessandro, let me tray to answer your comments:

- The AUTO mode in TSS maps directly to the automatic trigger in TSS. The way it works is: the AMCLKS (clock selected by AMCLKS) is divided down by the AMPSC (the preescaler) and then it counts up to SMOD. So if the selected clock is 1kHz and the preescaler is 1, then every count of SMOD is 1 ms. This is what processor expert is calculating. Important thing: the scan period configured out of this setting must be bigger than however long it takes to scan all the electrodes. If the timing is less, the TSI module will return an overrun error, or "small trigger period" as the TSS library calls it. Electrode scanning usually happens very fast, depending on the number of scans (determined by NSCN and PS) it can go down to uS range, and usually is within 1 or 2 ms. On the other hand, user reaction time is very slow, people don't usually detect what happens faster than 100 ms, so even if you were using the 16 electrodes (taking up about 16 ms to scan), you still would use a scan period of 50 to 100 ms, even more, without problems. This is why it works this way. Use SMOD/AMPSC to get around those values. Why so slow? Mainly to save power, you could scan more frequently, but in most cases it won't enhance the user experience, but it will increment power and CPU usage, better to keep those down.

- The setting of the bus clock and getting the LPOCLK is definitely an error that the SW team has been alerted about. It's inheritance from the very first TSI version that used to have the bus clock with that value. Later on it was found that the LPOCLK was much better suited, particularly due to the explanation provided above.

- The number of scans is actually like this: Number of scans = (NSCN + 1)*(PS^2). Notice that PS is different than AMPSC. PS preescales the number of scans. So setting NSCN to 8 with a PS of 0 would actually give 9 scans in normal conditions, but there is and errata that covers this situation, basically, if the time it takes for that number of scans is less than a preescaled clock source period, as you have correctly mentioned, the module will continue scanning for that period. This issue shall be fixed in a future mask release, but notice that the number of counts reported by the module is not affected. The errata is here: http://cache.freescale.com/files/microcontrollers/doc/errata/KINETIS72MHZ_1N36B.pdf It is e3926.

- The ALWAYS trigger mode will continually scan without any timing in between. The time between scans will depend on how many electrodes and how many scans you have configured. In this mode, the small trigger period is ignored, that is why you're having no problems.

My recommendation is to use the AUTO mode, make sure you set a slower period, as I mentioned before, 50 ms should be good.

451 Views
Vagni
Contributor IV

Hi Eduardo,

Thank you for your reply. I begin to understand TSI module much better.

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).

I am still confused about the AUTO trigger mode and the number of scans (maybe Number of scans = (NSCN + 1)*(2^PS) is the correct formula?)

I set 50ms as AUTO trigger period, as you suggested. But with TSS_Library Component I can only set the low and high limits for PS used in the autocalibration process executed at the application startup. So, the autocalibration process finds and set the best values for EXTCHRG and PS registers for a given bit resolution value of the TSI counter for each enabled electrode, but at that time the trigger period (50ms) and NSCN (8) are already set by the TSS initialization process.

Calling TSS_Task() every 5ms with those settings, I get the "Small Trigger Period" fault output by the TSS Library.

But I found I get no error if I call TSS_Task() continuously !!!

From the TSS API Reference Manual I see the Response Time Register, that sets the number of TSS_Task() calls required for an electrode status change detection. I left that register to the default value 4.

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