MPR121 seems like it freezes

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

MPR121 seems like it freezes

1,815 Views
kinna
Contributor I

Hi

I have a problem with the MPR121 Capacitive Touch Sensor Controller. I configured it as recommended in the Quick Start Guide and most of the time it works very well. I have only three electrodes connected and it responds nicely when I touch one and then releases. But if I touch all of them at once or quickly move my finger from one to another, it seems like it freezes. If I re-initialize the MPR121 it works again, but freezes again if I touch all the electrodes or quickly move my finger. 

I have checked that it is not the microcontroller, everything else is still running.

Does anyone know what I might have done wrong?

The configuration settings are shown here:

// Enter stop mode (for re-initialization)

  touch_set(0x5E,0x00);

  // Recommended filter settings when electrode data > baseline value

  // (rising)

  touch_set(0x2B,0x01);

  touch_set(0x2C,0x01);

  touch_set(0x2D,0x00);

  touch_set(0x2E,0x00);

  // Recommended filter settings when electrode data < baseline value

  // (falling)

  touch_set(0x2F,0x01);

  touch_set(0x30,0x01);

  touch_set(0x31,0xFF);

  touch_set(0x32,0x02);

  // Setting touch- and release thresholds for electrode 0

  touch_set(0x41,0x0F);

  touch_set(0x42,0x0A);

  // Setting touch- and release thresholds for electrode 1

  touch_set(0x43,0x0F);

  touch_set(0x44,0x0A);

  // Setting touch- and release thresholds for electrode 2

  touch_set(0x45,0x0F);

  touch_set(0x46,0x0A);

 

  // Setting sample rate to 1ms

  touch_set(0x5D,0x04);

  // Enable auto config and auto reconfig

  touch_set(0x7B,0x0B);

  touch_set(0x7D,0x9C);

  touch_set(0x7E,0x65);

  touch_set(0x7F,0x8C);

  // Enable touch on electrode 0-2 - this also enables the controller and

  // must be set as the last

  touch_set(0x5E,0x3);

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

1,179 Views
reyes
NXP TechSupport
NXP TechSupport

You should probably test it again using the following configuration:

#define TouchThre 10   //15//30//10

#define ReleaThre 6   //8//25//8

void MPR121_init(void)

{

  //Reset MPR121 if not reset correctly

  IIC_ByteWrite(0x80,0x63);  //Soft reset 

  IIC_ByteWrite(0x5E,0x00);  //Stop mode  

 

  //touch pad baseline filter

  //rising                                    

  IIC_ByteWrite(0x2B,0x01); // MAX HALF DELTA Rising

  IIC_ByteWrite(0x2C,0x01); // NOISE HALF DELTA Rising

  IIC_ByteWrite(0x2D,0x0E); // NOISE COUNT LIMIT Rising

  IIC_ByteWrite(0x2E,0x00); // DELAY LIMIT Rising

  //falling

  IIC_ByteWrite(0x2F,0x01); // MAX HALF DELTA Falling

  IIC_ByteWrite(0x30,0x05); // NOISE HALF DELTA Falling

  IIC_ByteWrite(0x31,0x01); // NOISE COUNT LIMIT Falling

  IIC_ByteWrite(0x32,0x00); // DELAY LIMIT Falling

  //touched

  IIC_ByteWrite(0x33,0x00); // Noise half delta touched

  IIC_ByteWrite(0x34,0x00); // Noise counts touched

  IIC_ByteWrite(0x35,0x00); // Filter delay touched

   

  

  //Touch pad threshold

 

  IIC_ByteWrite(0x41,TouchThre); // ELE0 TOUCH THRESHOLD

  IIC_ByteWrite(0x42,ReleaThre); // ELE0 RELEASE THRESHOLD

  IIC_ByteWrite(0x43,TouchThre); // ELE1 TOUCH THRESHOLD

  IIC_ByteWrite(0x44,ReleaThre); // ELE1 RELEASE THRESHOLD

  IIC_ByteWrite(0x45,TouchThre); // ELE2 TOUCH THRESHOLD

  IIC_ByteWrite(0x46,ReleaThre); // ELE2 RELEASE THRESHOLD

  

 

  //touch /release debounce

  IIC_ByteWrite(0x5B,0x00);

 

  // response time = SFI(10) X ESI(8ms) = 80ms

  IIC_ByteWrite(0x5D,0x13);    

  //FFI=18 

  IIC_ByteWrite(0x5C,0x80);  

 

 

  //Auto configuration

  IIC_ByteWrite(0x7B,0x8F); 

                                                                         

  // charge to 70% of Vdd , high sensitivity 

  IIC_ByteWrite(0x7D,0xE4);

  IIC_ByteWrite(0x7E,0x94);

  IIC_ByteWrite(0x7F,0xCD);

  //3 electrodes enabled    

  IIC_ByteWrite(0x5E,0x03);  

}

Let me know if you still have problems after this.

0 Kudos

1,179 Views
kinna
Contributor I

Thanks for your reply. I tried the configuration you wrote, but it still freezes when I move my fingers fast from one electrode to another.

I'm using an ATmega 328P as master with this setup:

void twi_master_init()

{

  // Set prescaler value to 1

  TWSR &= ~(1 << TWPS1) & ~(1 << TWPS0);

  // Set Bit Rate Register to 2 (clock division factor)

  TWBR = 0x2;

}

Could that have something to do with it?

0 Kudos

1,179 Views
reyes
NXP TechSupport
NXP TechSupport

It’s possible that the problem its timing related (it’s possible that you are not running at the 400 kHz needed for the MPR121).

But you can find a code example for the MPR121 using the ATmega328 on the link below, I would recommend you to test your MPR121 using the code on this link: https://www.sparkfun.com/products/9695

0 Kudos