Change Mode in GENCS (TSI) problem

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

Change Mode in GENCS (TSI) problem

Jump to solution
1,423 Views
MichaelDavid
Contributor III

Hi,

I'm working with kinetis KL05Z32

I'm trying to change the mode in GENCS register (TSI), but it stays 0.

here is the code(CW10.3):

// clear register relevant bits

  TSI0_GENCS &= ~(uint32_t)(TSI_GENCS_MODE_MASK|

       TSI_GENCS_DVOLT_MASK |

       TSI_GENCS_EXTCHRG_MASK |

       TSI_GENCS_TSIEN_MASK);

TSI0_GENCS |= (TSI_GENCS_MODE(0x4)| // noise sensing single                    

       TSI_GENCS_DVOLT(3) | // DVpm = 1.350V (DVOLT<1:0>,EXTCHRG<2:1> = 1110b)

       TSI_GENCS_EXTCHRG(4)); 

Please help.

Labels (1)
0 Kudos
1 Solution
1,040 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Michael,

I've receive the reply about the TSI_GENCS[MODE] verification from the AE team and the detail information as follows, please refer to it for details.

  1. About noise generating

KL noise detection mode is used especially for IEC61000-4-6 test, in which the noise (range from 150KHz to 230MHz) is injected into 220V AC power supply, other than from the touch pad.

  1. How 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;

}

For more details, please refer to KL05 Reference Manual “Automatic noise mode”.


Have a great day,
Ping

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

View solution in original post

0 Kudos
11 Replies
1,041 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Michael,

I've receive the reply about the TSI_GENCS[MODE] verification from the AE team and the detail information as follows, please refer to it for details.

  1. About noise generating

KL noise detection mode is used especially for IEC61000-4-6 test, in which the noise (range from 150KHz to 230MHz) is injected into 220V AC power supply, other than from the touch pad.

  1. How 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;

}

For more details, please refer to KL05 Reference Manual “Automatic noise mode”.


Have a great day,
Ping

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

0 Kudos
1,040 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Michael,

Did you debug your code on FRDM-KL05? What is the IDE you are using? Is it possible to send your project for a review? Thanks for your patience!


Have a great day,
B.R
Kan

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

0 Kudos
1,040 Views
MichaelDavid
Contributor III

Hi Kan,

I'm working on our custom board. IDE - CW10.3 eclipse version. I'll write a simple program on the FRDM board so you can check it also.

BR,

Michael David.

0 Kudos
1,040 Views
MichaelDavid
Contributor III

Hi Kan,

Attached is a simple example, based on the LED_Blink, with a initiation to the TSI only to check if the mode changes in the GENCS.

The IDE that I've worked with are CW10.3 and CW10.6, checked on FRDM-KL05. (example name is build/cw/LED_Blink_TSI)

BR,

Michael David.

0 Kudos
1,040 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Michael,

Sorry for the late response, my laptop got broken down and I just reinstalled it. For your example project, it works well on my FRDM-KL05Z, but I can see TSI0_GENCS is set with non-zero value,

1.png

so I am wondering if you want to change this register on the fly? but actually, RM states "

When TSI is working, the configuration bits (GENCS[TSIEN],

GENCS[TSIIEN], and GENCS[STM]) must not be changed.

The EOSF flag is kept until the software acknowledge it.

"

so if you want to change TSI0_GENCS when TSI is working, you have to wait for the end of scan by polling EOSF flag.


Have a great day,
Kan

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

0 Kudos
1,040 Views
MichaelDavid
Contributor III

Hi Kan,

As you can see even from your screen shut, the Mode bits in GENCS (24-27) stays 0, the other bits can be changed. these bit always stays null.

BR,

Michael David.

0 Kudos
1,040 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Michael ,

I just got the feedback, please refer to the following for details.

There 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. If TSI is working in a very peace environment the TSI_GENCS[MODE] will be read back as zero.


Hope that helps,


Have a great day,
Kan

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

0 Kudos
1,040 Views
MichaelDavid
Contributor III

Hi Kan,

Can you provide a simple provide simple code to clarify this procedure. because as I understand I should read the mode bits to get the noise?

0 Kudos
1,040 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Michael,

Shall we know your application? And what is the difficulty you meet?

The read back value is only useful under noise mode. Noise mode is used/works only under noisy environment. It can detect touch even by using noise itself.

Under noisy environment, if no touch, the callback will be 0 or 1; when touch, the callback may be A ~ F. This difference can be used to detect a touch.

Normally, cap mode and noise mode can be combined together by SW for a robust solution.


Have a great day,
Kan

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

0 Kudos
1,040 Views
MichaelDavid
Contributor III

Hi Kan,

I've tried to read the noise through the TSI_GENCS[MODE] and its always null. As you wrote I can easily see noise if I touch the pad. So, it still stays null. again please provide an example on the evaluation board that shows the correct handling of the noise.

BR,

Michael David.

0 Kudos
1,040 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Michael,

Maybe there is some misunderstanding. TSI_GENCS[MODE] functional under noisy environment, so would you please help to check if the read back value is non-zero when no touch? if yes, it means there is noise around the device, then you may read a different non-zero value when touch.

Hope that helps,


Have a great day,
Kan

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

0 Kudos