How to use TSI Noise Mode without TSS Library or Touch Software

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

How to use TSI Noise Mode without TSS Library or Touch Software

642 Views
joachimbeck
Contributor I

Hello,

we are using a MKL16Z processor and want to use the TSI without any Freescale library. We found the description of the TSI module in the Reference Manual a bit confusing especially regarding the noise mode.

The normal touch mode works well, but now we have problems with EMC (IEC61000-4-6 immunity). I tried to implement the algorithm which is described in the reference manual:

1. Initialize Rs = maxrs; Dvolt = minDv (set other configurations also)

2. Perform a noise cycle.

3. If TSIcounter < 3, go to step 8

4. If Rs = minrs, go to step 6.

5. Reduce value of Rs. go to step 2

6. If Dvolt = maxDv, go to END

7. Increase value of Dvolt. Set Rs = maxrs. go to step 2

8. If Rs > minrs, (Reduce value of Rs, go to END)

9. Rs = maxrs, reduce value of Dvolt.

10. END Get value of Rs and Dvolt.

My problem is, that I am not able to put this algorithm to code because I don't know exactly which values came in which registers.

Has anyone a working code snippet for this algorithm?

I understand that I get a noise value (0..15) out of this algorithm. I think to use it, I have to read this noise level on a cyclic manner parallel to the normal capacitance measurement to detect the noise. If it gets bigger than a threshold the touch will not be longer detected by the cap measurement, but by looking at the changes of the noise level. Is this right?

Thank you very much for your help.

Best regards

Joachim

Labels (1)
0 Kudos
1 Reply

370 Views
vicentegomez
NXP TechSupport
NXP TechSupport

Hi Joachim

First if TSI is working in a very peace enviroment the TSI_GENCS[MODE] will be read back as zero. Must be noise coupled to the TSI active channels and then TSI will signalize the noise level to 4bit number and return back to TSI_GENCS[MODE] for user to read.

To verify TSI_GENCS[MODE]

Set MODE[3:2] = 0b11, and inject noise into power supply, then read MODE bits, the MODE[3:0] is the noise level (value ranges 0-15), which is proportional to the noise injected.

Attached below is the example code:

//Measure TSI channel noise level value in noise mode

void tsi_measure_noise(unsigned char uChN)

{

//enable noise mode

TSI0_GENCS |= (TSI_GENCS_ESOR_MASK

                   | TSI_GENCS_MODE(12u)                // auto noise detection

                   | TSI_GENCS_DVOLT(0)                   // select voltage rails

                   | TSI_GENCS_EXTCHRG(0)              // use 32Kohm Rs, no filter

                   | TSI_GENCS_REFCHRG(Iref0p5u)

                   | TSI_GENCS_PS(3)

                   | TSI_GENCS_NSCN(16)

                   );

   

    //start channel scan

    TSI0_DATA &=  ~TSI_DATA_TSICH(0xF);     // clear channels

   

    TSI0_DATA |= TSI_DATA_TSICH(uChN);     // set channel ID

    TSI0_DATA |= TSI_DATA_SWTS_MASK;     // start sampling

   

     // wait for sampling done

    while (!(TSI0_GENCS & TSI_GENCS_EOSF_MASK));

    // read noise level

    uNoiseLevel[uChN] = (uint16_t)((TSI0_GENCS & TSI_GENCS_MODE_MASK) >> TSI_GENCS_MODE_SHIFT);

    // clear the flag

    TSI0_GENCS |= TSI_GENCS_EOSF_MASK;

}

I hope this will help you.

Have a great day,
Vicente

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos