MK20DX256 TSI Calibration

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

MK20DX256 TSI Calibration

822 Views
fabianbrings
Contributor I

Greetings everyone,

I have a possibly odd question. I would like to try to use the MK20 TSI module to perform very small capacitance measurements. This of course implies some sort of calibration. While playing with the module I noticed something odd: The resulting count did not scale linearly with the reference oscillator current as I would expect.

Let me back up for a second. I set up the module and attach an external 100 pF capacitor. When the prescaler and the measurement counter are set to one each and both currents are set to 2 uA this gives 100 counts, since the reference cap is 1 pF. I would expect that increasing the reference current would increase the counts in the same way. This is however not the case. Going to 4, 6, and 8 uA gives an almost linear increase, but above that the count pretty much stays the same. 

Am I missing something fundamental here? Is this behavior within the expected tolerances and I am demanding something to unusual? Or should I suspect that my controller's TSI module is faulty? I would greatly appreciate any feedback and will gladly provide more information if needed.

Thank you very much and best regards,

FB.

Labels (1)
0 Kudos
5 Replies

686 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Sorry for the later reply.

Could you provide the detailed MK20X256 product part number and related mask set (You could find it at Chip surface silk print)?

Thank you for the help!

best regards,

Mike

0 Kudos

686 Views
fabianbrings
Contributor I

Yes of course I can provide that information. I am not entirely sure which are the relevant numbers, but in total it says on the part: MK20DX256VLH7 3N36B CTAY1428B. So I guess it's the 3N36B mask set.

Thank you for your time and best regards,

FB.

0 Kudos

686 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I checked K20_72MHz mask set 3N36B related errata file with TSI e2638 item:

pastedImage_1.png

Please add a delay of 0.25ms or greater prior to accessing the counter registers.

Please let me know if there still with the same issue.

best regards,

Mike

0 Kudos

686 Views
fabianbrings
Contributor I

You are right, I forgot that part of the errata. I read out the register inside the TSI interrupt routine. However adding a delay of 1 ms does not change the result. For clarity I provide my sourcecode, it is in Arduino style, but I think the general functionality is still understandable.

#define nscn 0 // number of scans

#define pres 0 // scan number prescaler

#define iele 0 // electrode dis-/charge current

#define iref 7 // reference oscillator dis-/charge current

uint16_t val;

double c;

void tsi0_isr() {

      delay(1);

      val = (TSI0_CNTR9 >> 16) & 0xFFFF; // read content of the output register

      TSI0_GENCS |= TSI_GENCS_EOSF;

      NVIC_CLEAR_PENDING(IRQ_TSI);

}

void setup() {

      Serial.begin(9600);

      SIM_SCGC5 |= SIM_SCGC5_TSI; // enable tsi clock

      TSI0_GENCS = 0; // reset tsi module

      TSI0_PEN = (1 << 9); // enable channel 9 (pin 0) // set dis-/charge currents

      TSI0_SCANC |= TSI_SCANC_REFCHRG(iref) | TSI_SCANC_EXTCHRG(iele); // set scan number + prescaler, activate module

      TSI0_GENCS |= TSI_GENCS_NSCN(nscn) | TSI_GENCS_PS(pres);

      TSI0_GENCS |= TSI_GENCS_TSIIE | TSI_GENCS_ESOR;

      TSI0_GENCS |= TSI_GENCS_TSIEN; NVIC_ENABLE_IRQ(IRQ_TSI);

}

void loop() {

      TSI0_GENCS |= TSI_GENCS_SWTS;

      delay(1000);

      // using Figure 50-39. Equation 5 from the reference manual to calculate the capacitance

      c = (double)val * (iele + 1) / ((nscn + 1) * (1 << pres) * (iref + 1));

      Serial.print(val); Serial.print(": "); Serial.print(c, 8); Serial.println(" pF");

}

0 Kudos

686 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

First of all, sorry for the later reply.

Please try with below TSI parameter setting:

#define nscn 10 // number of scans

#define pres 3 // scan number prescaler

#define iele 3 // electrode dis-/charge current

#define iref 31 // reference oscillator dis-/charge current

Wish it helps.

Mike

0 Kudos