Jump to content

Search the Community

Showing results for tags 'MPR121'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks


There are no results to display.

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 1 result

  1. Hello All! I'm having trouble achieving I2C communication with Sparkfun's MPR121 I2C capacitive touch sensor breakout board. I've used the breakout board (and code) many times before with the Arduino, but for some reason I can't get it to work with the MSP430G2553 and Energia. I'm using an MPR121 library found at http://bildr.org/2011/05/mpr121_arduino/ to help with register configuration. My code compiles fine, but I'm trying to print the output from the touch sensor to the serial monitor and nothing is showing up, so I'm assuming the touch sensor isn't working. I know the serial monitor works fine; I ran the DigitalReadSerial example and I can see the output on the monitor. I've connected the MPR121's SDA to pin 1.7 and the SCL to pin 1.6, and the IRQ (interrupt request) to pin 2.4. The SDA and SCL both have 10K pull up resistors on the MPR121's breakout board. The MPR121 is connected to Vcc and GND on the launchpad. Here is my code: #include <mpr121.h> #include <Wire.h> boolean touchStates[12]; //to keep track of the previous touch states void setup(){ pinMode(P2_4, INPUT); // IRQ pin digitalWrite(P2_4, HIGH); //enable pullup resistor Serial.begin(9600); Wire.begin(); mpr121_setup(); } void loop(){ readTouchInputs0(); } void readTouchInputs0(){ if(!checkInterrupt1()){ //read the touch state from the MPR121 Wire.requestFrom(90,2); byte LSB0 = Wire.read(); byte MSB0 = Wire.read(); uint16_t touched = ((MSB0 << 8) | LSB0); //16bits that make up the touch states for (int i=0; i < 12; i++){ // Check what electrodes were pressed if(touched & (1<<i)){ if(touchStates == 0){ //pin i was just touched Serial.print("pin "); Serial.print(i); Serial.println(" was just touched"); }else if(touchStates == 1){ //pin i is still being touched } touchStates = 1; }else{ if(touchStates == 1){ Serial.print("pin "); Serial.print(i); Serial.println(" is no longer being touched"); //pin i is no longer being touched } touchStates = 0; } } } } void mpr121_setup(void){ set_register(0x5A, ELE_CFG, 0x00); // Section A - Controls filtering when data is > baseline. set_register(0x5A, MHD_R, 0x01); set_register(0x5A, NHD_R, 0x01); set_register(0x5A, NCL_R, 0x00); set_register(0x5A, FDL_R, 0x00); // Section B - Controls filtering when data is < baseline. set_register(0x5A, MHD_F, 0x01); set_register(0x5A, NHD_F, 0x01); set_register(0x5A, NCL_F, 0xFF); set_register(0x5A, FDL_F, 0x02); // Section C - Sets touch and release thresholds for each electrode set_register(0x5A, ELE0_T, TOU_THRESH); set_register(0x5A, ELE0_R, REL_THRESH); set_register(0x5A, ELE1_T, TOU_THRESH); set_register(0x5A, ELE1_R, REL_THRESH); set_register(0x5A, ELE2_T, TOU_THRESH); set_register(0x5A, ELE2_R, REL_THRESH); set_register(0x5A, ELE3_T, TOU_THRESH); set_register(0x5A, ELE3_R, REL_THRESH); set_register(0x5A, ELE4_T, TOU_THRESH); set_register(0x5A, ELE4_R, REL_THRESH); set_register(0x5A, ELE5_T, TOU_THRESH); set_register(0x5A, ELE5_R, REL_THRESH); set_register(0x5A, ELE6_T, TOU_THRESH); set_register(0x5A, ELE6_R, REL_THRESH); set_register(0x5A, ELE7_T, TOU_THRESH); set_register(0x5A, ELE7_R, REL_THRESH); set_register(0x5A, ELE8_T, TOU_THRESH); set_register(0x5A, ELE8_R, REL_THRESH); set_register(0x5A, ELE9_T, TOU_THRESH); set_register(0x5A, ELE9_R, REL_THRESH); set_register(0x5A, ELE10_T, TOU_THRESH); set_register(0x5A, ELE10_R, REL_THRESH); set_register(0x5A, ELE11_T, TOU_THRESH); set_register(0x5A, ELE11_R, REL_THRESH); // Section D // Set the Filter Configuration // Set ESI2 set_register(0x5A, FIL_CFG, 0x04); // Section E // Electrode Configuration // Set ELE_CFG to 0x00 to return to standby mode set_register(0x5A, ELE_CFG, 0x0C); // Enables all 12 Electrodes // Section F // Enable Auto Config and auto Reconfig /*set_register(0x5A, ATO_CFG0, 0x0B); set_register(0x5A, ATO_CFGU, 0xC9); // USL = (Vdd-0.7)/vdd*256 = 0xC9 @3.3V set_register(0x5A, ATO_CFGL, 0x82); // LSL = 0.65*USL = 0x82 @3.3V set_register(0x5A, ATO_CFGT, 0xB5);*/ // Target = 0.9*USL = 0xB5 @3.3V set_register(0x5A, ELE_CFG, 0x0C); } boolean checkInterrupt1(void){ return digitalRead(P2_4); } void set_register(int address, unsigned char r, unsigned char v){ Wire.beginTransmission(address); Wire.write®; Wire.write(v); Wire.endTransmission(); }
  • Create New...