Created Tue, 09 Dec 2014 20:44:25 +0000 by alexceltare2
Tue, 09 Dec 2014 20:44:25 +0000
Hi guys, I just purchased the MPR121 capacitive keypad for my uni. project and I wish to hook it up with MPIDE. I've downloaded the example code from: [url]https://learn.sparkfun.com/tutorials/mpr121-hookup-guide[/url] but it gives me some errors relating "This sketch or library use AVR-specific code that may not work with the chipKit platform." Can you give me guys some advice please? Thank you.
Fri, 12 Dec 2014 19:47:47 +0000
I've done a short look at the library: Huge I2C routines, maybe one IRQ routine, but nothing AVR specific. So my "advise" is: Maybe it's easier for us, if you post the exactly error and the line of code the error belongs.
Fri, 12 Dec 2014 20:36:15 +0000
It's probably including an AVR specific header. The latest MPIDE has better support for these AVR specific headers, so you might like to try grabbing the latest version and giving it a whirl.
[url]http://chipkit.s3.amazonaws.com/index.html[/url]
Sat, 13 Dec 2014 00:58:50 +0000
I've done a short look at the library: Huge I2C routines, maybe one IRQ routine, but nothing AVR specific. So my "advise" is: Maybe it's easier for us, if you post the exactly error and the line of code the error belongs.
Compiling the MPR121 keypad example code shows this in the message box:
In file included from D:\Documents\mpide\libraries\MPR121/i2c.h:3:0, from MPR121_Keypad.cpp:21: C:\Program Files\mpide-0023\hardware\pic32\cores\pic32/avr/io.h:4:2: error: #error ******** This sketch or library uses AVR-specific code that may not work with the chipKIT platform. See this forum for more information on porting code to chipKIT [www.chipkit.org/forum/viewforum.php?f=7] ******** In file included from D:\Documents\mpide\libraries\MPR121/i2c.h:4:0, from MPR121_Keypad.cpp:21: C:\Program Files\mpide-0023\hardware\pic32\cores\pic32/avr/interrupt.h:4:2: error: #error ******** This sketch or library uses AVR-specific code that may not work with the chipKIT platform. See this forum for more information on porting code to chipKIT [www.chipkit.org/forum/viewforum.php?f=7] ******** In file included from MPR121_Keypad.cpp:21:0: D:\Documents\mpide\libraries\MPR121/i2c.h:84:15: error: variable or field 'delay_ms' declared void D:\Documents\mpide\libraries\MPR121/i2c.h:84:15: error: 'uint16_t' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h: In function 'void i2cInit()': D:\Documents\mpide\libraries\MPR121/i2c.h:102:2: error: 'TWCR' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:102:2: error: 'uint8_t' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:102:2: error: 'TWEN' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h: In function 'void i2cSetBitrate(short unsigned int)': D:\Documents\mpide\libraries\MPR121/i2c.h:110:2: error: 'TWSR' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:110:2: error: 'uint8_t' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:110:2: error: expected ')' before '~' token D:\Documents\mpide\libraries\MPR121/i2c.h:111:2: error: expected ')' before '~' token D:\Documents\mpide\libraries\MPR121/i2c.h:117:2: error: 'TWBR' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h: In function 'void i2cSendStart()': D:\Documents\mpide\libraries\MPR121/i2c.h:122:2: error: 'DDRC' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:124:2: error: 'TWCR' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:124:13: error: 'TWINT' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:124:24: error: 'TWSTA' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:124:35: error: 'TWEN' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h: In function 'void i2cSendStop()': D:\Documents\mpide\libraries\MPR121/i2c.h:130:9: error: 'TWCR' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:130:20: error: 'TWINT' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:130:31: error: 'TWEN' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:130:41: error: 'TWSTO' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h: In function 'void i2cWaitForComplete()': D:\Documents\mpide\libraries\MPR121/i2c.h:138:15: error: 'TWCR' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:138:26: error: 'TWINT' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h: In function 'void i2cSendByte(unsigned char)': D:\Documents\mpide\libraries\MPR121/i2c.h:144:12: error: 'delay_ms' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:146:2: error: 'DDRC' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:148:2: error: 'TWDR' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:150:2: error: 'TWCR' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:150:13: error: 'TWINT' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:150:24: error: 'TWEN' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h: In function 'void i2cReceiveByte(unsigned char)': D:\Documents\mpide\libraries\MPR121/i2c.h:159:3: error: 'TWCR' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:159:3: error: 'TWINT' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:159:3: error: 'TWEA' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:164:3: error: 'TWCR' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h:164:3: error: 'TWINT' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h: In function 'unsigned char i2cGetReceivedByte()': D:\Documents\mpide\libraries\MPR121/i2c.h:171:10: error: 'TWDR' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h: In function 'unsigned char i2cGetStatus()': D:\Documents\mpide\libraries\MPR121/i2c.h:177:10: error: 'TWSR' was not declared in this scope D:\Documents\mpide\libraries\MPR121/i2c.h: At global scope: D:\Documents\mpide\libraries\MPR121/i2c.h:180:15: error: variable or field 'delay_ms' declared void D:\Documents\mpide\libraries\MPR121/i2c.h:180:15: error: 'uint16_t' was not declared in this scope In file included from C:\Program Files\mpide-0023\hardware\pic32\cores\pic32/WProgram.h:12:0, from MPR121_Keypad.cpp:42: C:\Program Files\mpide-0023\hardware\pic32\cores\pic32/wiring.h:332:21: error: expected declaration before end of line
Sat, 13 Dec 2014 01:02:08 +0000
It's probably including an AVR specific header. The latest MPIDE has better support for these AVR specific headers, so you might like to try grabbing the latest version and giving it a whirl. [url]http://chipkit.s3.amazonaws.com/index.html[/url]
Is the test version ok for developing? I have the latest stable release 0023.2014.08.21
PS. Thanks guys for your kind replies.
Sat, 13 Dec 2014 10:59:33 +0000
It's fine for developing, for certain values of fine. You can run both the stable and the test versions in parallel and switch between them at will, so download the latest version and try it out. If it works, great, if not then we need to look deeper into the library to see what it needs.
Incidentally, it looks like we're going to soon be releasing a new stable version from the test version. We need to do some more tests yet (so you using the test version and finding bugs would be good), but it shouldn't be long now...
Mon, 15 Dec 2014 19:09:01 +0000
The new release still gives me the error on compilation as seen before :cry: And sorry, the code is actually in: [url]https://www.sparkfun.com/products/12017[/url] and check Example code. Is the MPR121 Capacitive touchpad. Do I need some different way of hooking up the system? Please help
Mon, 15 Dec 2014 19:55:23 +0000
Ah, it's written by typical clueless Arduino muppets,
There's two fundamental things wrong with that code:
It has functions in header files. That's a huge no-no in C programming, unless they are static, which they aren't. That immediately tells me they don't really have much of a clue about programming
It has a whole load of custom functions for talking to I2C instead of using the standard Wire library. This means that code will never work on anything other than an Arduino.
Hell, they're so clueless they even seem to have a delay_ms() function that runs a tight nop() loop instead of just using delay(). It's like they copied and pasted enough code from other places to "just make it work", which is pretty much right for most Arduino users...
So you should instead use that library as a set of clue and hints about how to talk to the keypad, and write your own software for it.
It's all I2C, so massive amounts of their code can be replaced with proper Wire functions. The main bits to re-write are in mpr121Read and mpr121Write it would seem.
Mon, 15 Dec 2014 20:26:04 +0000
Sir, please, I'm new to Arduino and consider myself a noob. And I have no idea how to use the Wire.h library. Some help please? Or is it possible to use just 1 function to output the values of the keypad to Serial Port maybe?
Mon, 15 Dec 2014 20:37:08 +0000
I see Adafruit also do an MPR121 board. Adafruit are much better at writing libraries - they have a clue. You might try their library instead:
[url]https://github.com/adafruit/Adafruit_MPR121_Library/archive/master.zip[/url]
It has a much greater chance of working, or only needing minor adjustments to make it work.
Mon, 15 Dec 2014 21:06:58 +0000
I still get dozens of errors :cry: Is ok man, I will see what I can do. Thank a lot for your help. I appreciate.
Mon, 15 Dec 2014 23:12:48 +0000
And what are the errors? Are they about things like "no such method write()" or similar?
Mon, 15 Dec 2014 23:47:20 +0000
D:\Documents\mpide\libraries\Adafruit_MPR121\Adafruit_MPR121.cpp: In member function 'uint8_t Adafruit_MPR121::readRegister8(uint8_t)':
D:\Documents\mpide\libraries\Adafruit_MPR121\Adafruit_MPR121.cpp:103:31: error: no matching function for call to 'TwoWire::endTransmission(int)'
C:\Program Files\MPIDE\.\hardware\pic32\libraries\Wire/Wire.h:96:13: note: candidate is: uint8_t TwoWire::endTransmission()
D:\Documents\mpide\libraries\Adafruit_MPR121\Adafruit_MPR121.cpp:105:19: error: 'class TwoWire' has no member named 'read'
D:\Documents\mpide\libraries\Adafruit_MPR121\Adafruit_MPR121.cpp: In member function 'uint16_t Adafruit_MPR121::readRegister16(uint8_t)':
D:\Documents\mpide\libraries\Adafruit_MPR121\Adafruit_MPR121.cpp:111:31: error: no matching function for call to 'TwoWire::endTransmission(int)'
C:\Program Files\MPIDE\.\hardware\pic32\libraries\Wire/Wire.h:96:13: note: candidate is: uint8_t TwoWire::endTransmission()
D:\Documents\mpide\libraries\Adafruit_MPR121\Adafruit_MPR121.cpp:113:23: error: 'class TwoWire' has no member named 'read'
D:\Documents\mpide\libraries\Adafruit_MPR121\Adafruit_MPR121.cpp:114:28: error: 'class TwoWire' has no member named 'read'