Pages: [1]   Go Down
Author Topic: Is it possible to use I2C with SPI?  (Read 456 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've got a magnetometer (micromag 3) on SPI and an accelerometer (lis3lv02dq) on I2C, each working independently, through different pins.  I've had some trouble combining the code into one.


I know it's a generic question, but I want to know:  

Is it possible with the arduino?  Is there any factors to consider when integrating them that you don't have to think about when coding the individual interfaces?


(I know it would be far more elegant to have them both on the same SPI bus, since the lis can do SPI, but this is proof of concept and needs to be done quickly)


Many thanks

hugh
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 83
I do my own experiments.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you trying to poll them for data concurrently or one and then the other? Are the pins used for each bus separate?

Are you using the hardware i2c pins and support or are you bit banging i2c?

Your problem is more in what you're doing than a question of possibilities.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm *trying* to do it one then the other - I'm wrapping the individual parts in function calls, and calling the ones for I2C THEN the ones for SPI.

I'm using different pins for each bus.

I'm using hardware i2c pins  (analog 4 + 5 on the duemilanove - as used by the wire.h lib).


It's great that it's possible!  It means I'm not barking up the wrong tree. smiley-wink

I'm just having an overhaul/debug of my code, and then I'll post it/the relevant bits.  It's not pretty, but I'm afraid this is my first bit arduino project.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 513
Posts: 31529
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I know it's a generic question, but I want to know:  
Is it possible with the arduino?

Yes it is possible, they use totally different pins and different hardware inside the processor.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Grumpy_mike, there's never been a problem I've had when you haven't been part of the cavalry!  I admire the commitment to giving the newbies a hand-up. smiley-grin


I just did my debug/rebuild run, and I sorted out the problem - it's working absolutely fine right now smiley-grin!  Thankyou too Kyle, for weighing in.

Ah, the sweet feeling of success!
Logged

Pages: [1]   Go Up
Jump to: