CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

ADXL345 I2C

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pablopaolus



Joined: 13 May 2012
Posts: 5
Location: SPAIN

View user's profile Send private message

ADXL345 I2C
PostPosted: Tue May 07, 2013 11:48 am     Reply with quote

Hi everybody,

I've already read all threads related to this topic in the forum, but I've not been able to solve my problem, so let me create a new one.

I'm working with PIC18F46J50 and Sparkfun IMU 6DOF ITG3200/ADXL345 (https://www.sparkfun.com/products/10121). For now, I'm trying to read accelerometer measures without success.

First of all, I have an essential doubt which I think could be the problem... Sorry if I'm asking a nonsense: I'm using I2C pins D1 (SDA2) and D0 (SCL2) because I need the SDA1 and SCL1 ones for SPI purposes. So in my code:

Code:
#use I2C(MASTER, SDA=PIN_D1, SCL=PIN_D0)


However, I've read from some thread about adxl345 that the option "FORCE_HW" was needed to make it work. I get the error " Option invalid Wrong pins for H/W" if I write this option (which wouldn't happen if I used SDA1 and SCL1 pins, but I can't).

I don't know if I have explained well enough... Could this be a problem, assuming my code is correct?

Thanks a lot.
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Tue May 07, 2013 12:24 pm     Reply with quote

There should not be any I2C device that _requires_ hardware operation. Generally software I2C, is much more likely to work!...

However the reason you can't select hardware, is you have not told the chip to use the hardware.
The syntax you need is:
Code:

#PIN_SELECT SCK2=PIN_D0
#PIN_SELECT SDI2=PIN_D1
//Tell the compiler which pins to use....
#use I2C(MASTER, I2C2)
//Tell the compiler to use the hardware port that is now connected
//to the required pins


You should also manually set the pins as inputs (this is the default, but the compiler will not set tris for you).

This is common for all peripherals using PPS.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group