Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Bascom ADXL345 via I²C -no response by device

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
autoguider

Bascom Member



Joined: 24 Sep 2007
Posts: 82
Location: Aachen

germany.gif
PostPosted: Fri Sep 27, 2019 2:20 pm    Post subject: Bascom ADXL345 via I²C -no response by device Reply with quote

Dear all,
I do my first steps with I²C on Bascom so it may be that I do not see the trees because of the forest.
I want to run a ADXL345 accelerometer via I²C.
The accelerometer is on a breakout board installed on a breadboard. MCU runs on Arduino UNO R3 board.
SCA,SCL are pulled HIGH to VDD=5V via 2k4 resistors.
SDO , which to my opinion is the AltAddress pin is fixed to VDD.

This has now influence on the codes for reading and writing to registers.

As I understand the datasheet the 7 bit slave address is 0011101.
To complete it to a byte the LSBit is attached to the right hand side. 1 for read ; 0 for write
So the command after the start announcing a writing access is 00111010 (3A)
So the command after the start announcing a reading access is 00111011 (3B)

I also integrated a bus scanner in the program.
No slave is found by the scan.

The code is attached.

Please be so kind to give me some advice.

Best regards
Christian

(BASCOM-AVR version : 2.0.8.1 , Latest : 2.0.8.2 )
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2335

blank.gif
PostPosted: Fri Sep 27, 2019 6:10 pm    Post subject: Reply with quote

There are some hits doing a forum search for ADXL345.

Last edited by MWS on Fri Sep 27, 2019 8:01 pm; edited 1 time in total
Back to top
View user's profile
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1571
Location: Basel, Switzerland

switzerland.gif
PostPosted: Fri Sep 27, 2019 7:47 pm    Post subject: Reply with quote

Hi,

I've had a quick look at your code and I can't see where you configure and initalise the i2c bus.

You Need to include something like this to Setup the i2c bus before you use it:

Code:

Config Sda = portc.1                                        'setup I2C bus
Config Scl = portc.0
Config I2cdelay = 10                                        '100KHz i2c bus
I2cinit                                                     'Initalise i2c bus
 


Regards
Ian Dobson

_________________
Walking on water and writing software to specification is easy if they're frozen.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
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
You cannot attach files in this forum
You cannot download files in this forum