Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Which i2c library?
30-03-2013, 01:10 PM,
#1
Which i2c library?
Hi,
I'm trying to persuade my Pinguino-OTG to talk to an ADXL345 using i2c but am (easily) confused by the number of libraries to choose from. E.g i2c.c, pinguinoi2c1.c to say nothing of I2CP32MX

Which one should I be using?

Any help would be gratefully received.

Best Regards
Keith
Reply
30-03-2013, 05:05 PM,
#2
RE: Which i2c library?
Hi


Normally you need both libraries, i2c.c is the basic library and pinguinoi2c1.c and pinguinoi2c2.c are only a wrap of the i2c calls for specific I2C channel.
These wrap libraries are used in i2c.pdl32 (only channel 1).

If you want develop a program use directly Pdl calls otherwise use the call of i2c.c


Bye Bye, Moreno
Reply
31-03-2013, 04:22 PM,
#3
RE: Which i2c library?
(30-03-2013, 05:05 PM)moreno Wrote: Hi


Normally you need both libraries, i2c.c is the basic library and pinguinoi2c1.c and pinguinoi2c2.c are only a wrap of the i2c calls for specific I2C channel.
These wrap libraries are used in i2c.pdl32 (only channel 1).

If you want develop a program use directly Pdl calls otherwise use the call of i2c.c


Bye Bye, Moreno

Hi Moreno,
Many thanks for your swift response.

As you may have gathered I'm very much a novice so have a limited understanding.

I've simplified my code as far as I can to try to understand what's happening

void setup()
{


I2C.init();
CDC.print("Sent init \r\n");
I2C.start();
delay(1000);
CDC.print("Sent start \r\n");
I2C.writechar(0xa6);
CDC.print("Sent address \r\n");
delay(100);
// I2C.writechar(0x31);
// I2C.writechar(0x01);
//I2C.writechar(0x2d);
// I2C.writechar(0x08);
I2C.stop();
CDC.print("Ending setup \r\n\r\n");

}


void loop() {

}
The output I get from minicom is

Sent init
-1660896544Sent address
-1660896512

Where those numbers come from I've no idea and why "Sent start" is missing is a mystery!
0xA6 is the address of the device (0x53) with write bit added.

Best Regards
Keith
Reply
01-04-2013, 09:55 AM,
#4
RE: Which i2c library?
Shorten yur CDC strings. The USB CDC does not busy-wait to send the full data so some gets lost.

Won't fix i2c but at least debug will be better!

John
Reply
24-06-2013, 03:55 PM, (This post was last modified: 24-06-2013, 04:27 PM by nikolajpp.)
#5
RE: Which i2c library?
Have you had any success? - I am trying to get the adxl345 online -however its quite harder than in the arduino environment where i just had to import a librarySmile
Please let me know if you where successfullSmile
Reply
02-12-2013, 03:00 PM,
#6
RE: Which i2c library?
Guys, I posted a simple working example a few days ago.

http://forum.pinguino.cc/showthread.php?tid=4179

REMEMBER to fix that code by replacing the "Serial." line by "CDC." or it will hang. (that was the reason for the error in the post)

You can use the Wire library. And your code will be almost compatible with any arduino. It will make things easier if you want to port the application!

Pinguino internally replaces Wire references by the correct I2C library and you don't have to worry about anything else.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)