10 years, 7 months ago.

another newbie question

Hi again,

and thank your for your response from my last question.

I've been studying many different 3axis drivers on the site.

I'm again stuck on reading in-depth your simple driver. Again it's around register values. In your main, you write to register 0x2A - 0x01 for initialisation - however from the pdf for this accelerometer it indicates a register called: CTRL_REG_1. You are writing a value of 0x01 to this register? Why?

In the main while loop you write to register 0x01 and do not send a 'stop' on the bus, as you then do a read later. This makes a bit of sense as this is for xaxis according to the pdf. :-) After this you do a read - but you read 6 octets, and split into x,y and z.

First 2 octets for x, next 2 for y and the last for z.

I assumed you would have to write - read from register 0x03 for y and register 0x05 for z to get those values!

You only asked for a write - read on register 0x01 .....

Any way you could point me in the correct direction to explain this?

Kind regards, Nicholas Herriot.

Question relating to:

1 Answer

10 years, 7 months ago.

Regarding your first question, see also what the datasheet says about CTRL_REG_1 (page 38): bit 0 is the active bit, you activate the IC by writing a 1 to that register.

For your second question, most ICs use auto-increment. So if you write the address you want to read from, then after that you can just keep on reading and you get the value on the next address.

So first two are for x-value. Then automatically the address becomes the first y-value register and you read that one, etc.

Accepted Answer

Thank you Erik.

Finding this type of information out by reading the pdf's is difficult unless you have familiarity. I'm grateful for your help... :-)

Kind regards, Nicholas

posted by Nicholas Herriot 04 Oct 2013