MPR121 Autoconfiguration

cancel
Showing results for 
Search instead for 
Did you mean: 

MPR121 Autoconfiguration

Jump to solution
1,101 Views
markthedark
Contributor III

I have some questions about the MPR121 Touch Sensor Auto configuration sequence that is not explained well in the Reference Manual or Application Notes.

1. What is the purpose of the Target Level register?

2. How can I tell when the Auto-complete sequence is complete?

3. Is there source code or a flow chart of how the Auto-complete should be coded?


Thanks in advance.

1 Solution
234 Views
Joshevelle
Senior Contributor I

Hello Mark,

I noticed that you entered SR#1-948472563 for this inquiry and we already sent you a response.

However, I thought that the suggested initialization code might be useful for you:

#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

  IIC_ByteWrite(0x47,TouchThre); // ELE3 TOUCH THRESHOLD

  IIC_ByteWrite(0x48,ReleaThre); // ELE3 RELEASE THRESHOLD

  IIC_ByteWrite(0x49,TouchThre); // ELE4 TOUCH THRESHOLD

  IIC_ByteWrite(0x4A,ReleaThre); // ELE4 RELEASE THRESHOLD

  IIC_ByteWrite(0x4B,TouchThre); // ELE5 TOUCH THRESHOLD

  IIC_ByteWrite(0x4C,ReleaThre); // ELE5 RELEASE THRESHOLD

  IIC_ByteWrite(0x4D,TouchThre); // ELE6 TOUCH THRESHOLD

  IIC_ByteWrite(0x4E,ReleaThre); // ELE6 RELEASE THRESHOLD

  IIC_ByteWrite(0x4F,TouchThre); // ELE7 TOUCH THRESHOLD

  IIC_ByteWrite(0x50,ReleaThre); // ELE7 RELEASE THRESHOLD

  IIC_ByteWrite(0x51,TouchThre); // ELE8 TOUCH THRESHOLD

  IIC_ByteWrite(0x52,ReleaThre); // ELE8 RELEASE THRESHOLD

  IIC_ByteWrite(0x53,TouchThre); // ELE9 TOUCH THRESHOLD

  IIC_ByteWrite(0x54,ReleaThre); // ELE9 RELEASE THRESHOLD

  IIC_ByteWrite(0x55,TouchThre); // ELE10 TOUCH THRESHOLD

  IIC_ByteWrite(0x56,ReleaThre); // ELE10 RELEASE THRESHOLD

  IIC_ByteWrite(0x57,TouchThre); // ELE11 TOUCH THRESHOLD

  IIC_ByteWrite(0x58,ReleaThre); // ELE11 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);

  // 12 electrodes enabled    

  IIC_ByteWrite(0x5E,0xCC);  

}

...hope it helps! =)

Josh

View solution in original post

0 Kudos
2 Replies
234 Views
Janosch
Contributor II

Hello,

i would be still very interested in #2 of the original question:

Mark Donkers schrieb:

2. How can I tell when the Auto-complete sequence is complete?

Is there any way to determine, or at least to take a good guess, when the auto-calibration of the sensor is completed?

Thanks

Janos

0 Kudos
235 Views
Joshevelle
Senior Contributor I

Hello Mark,

I noticed that you entered SR#1-948472563 for this inquiry and we already sent you a response.

However, I thought that the suggested initialization code might be useful for you:

#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

  IIC_ByteWrite(0x47,TouchThre); // ELE3 TOUCH THRESHOLD

  IIC_ByteWrite(0x48,ReleaThre); // ELE3 RELEASE THRESHOLD

  IIC_ByteWrite(0x49,TouchThre); // ELE4 TOUCH THRESHOLD

  IIC_ByteWrite(0x4A,ReleaThre); // ELE4 RELEASE THRESHOLD

  IIC_ByteWrite(0x4B,TouchThre); // ELE5 TOUCH THRESHOLD

  IIC_ByteWrite(0x4C,ReleaThre); // ELE5 RELEASE THRESHOLD

  IIC_ByteWrite(0x4D,TouchThre); // ELE6 TOUCH THRESHOLD

  IIC_ByteWrite(0x4E,ReleaThre); // ELE6 RELEASE THRESHOLD

  IIC_ByteWrite(0x4F,TouchThre); // ELE7 TOUCH THRESHOLD

  IIC_ByteWrite(0x50,ReleaThre); // ELE7 RELEASE THRESHOLD

  IIC_ByteWrite(0x51,TouchThre); // ELE8 TOUCH THRESHOLD

  IIC_ByteWrite(0x52,ReleaThre); // ELE8 RELEASE THRESHOLD

  IIC_ByteWrite(0x53,TouchThre); // ELE9 TOUCH THRESHOLD

  IIC_ByteWrite(0x54,ReleaThre); // ELE9 RELEASE THRESHOLD

  IIC_ByteWrite(0x55,TouchThre); // ELE10 TOUCH THRESHOLD

  IIC_ByteWrite(0x56,ReleaThre); // ELE10 RELEASE THRESHOLD

  IIC_ByteWrite(0x57,TouchThre); // ELE11 TOUCH THRESHOLD

  IIC_ByteWrite(0x58,ReleaThre); // ELE11 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);

  // 12 electrodes enabled    

  IIC_ByteWrite(0x5E,0xCC);  

}

...hope it helps! =)

Josh

View solution in original post

0 Kudos