You are here

adxl345 with spi | Cypress Semiconductor

adxl345 with spi

Summary: 20 Replies, Latest post by Bob Marlowe on 27 Oct 2016 12:54 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
rushin010's picture
User
32 posts

 hello there from this posthttp://www.cypress.com/forum/psoc-4-ble/psoc-4-ble-adxl362-problem i am trying to interface adxl345 with  cy8c4247AZI-M485. but i am not getting data . can you help me??

Attachments: 
user_1377889's picture
User
9590 posts

Two things to mention at first sight:

Writing to ss wil fail because it is connected (wired) to your SPI device. Remove the connection and uncheck in pin's configuration "Hardware Connect".

 

You are writing 2 bytes, but you are retrieving only one byte. Keep in mind that for every byte sent you get one byte back. So your while-loop will certainly end with the first byte in buffer, but without the second.

 

Bob

rushin010's picture
User
32 posts

hey thanks for your reply. i made changes. but still i am getting 0x00. i have uploaded project here

Attachments: 
user_1377889's picture
User
9590 posts

Have a look into adxl345's datasheet and adjust your CPHA and CPOL accordingly.

I would suggest you to put some more emphasis on a clear and readable structure of your program, no explanations yet, nearly no comments so far and bad indentation. Allocating variables in the middle of a function does not make reading easier... You even do not mention which board the project is made for and that you are accessing an adxl345. In a few months, aftert some other projects done, you will have difficulties to remember all those facts when looking at the sources.

 

Bob

rushin010's picture
User
32 posts

ok thanks for your support

rushin010's picture
User
32 posts

i set according to datasheet. but i am not getting data. 0x00 is device id register. i should return E5 . but i am getting 0x00

user_1377889's picture
User
9590 posts

...and your latest project state?

 

Bob

 

rushin010's picture
User
32 posts

thanks for your support. its working. actually i had made mistake in pin assignment

rushin010's picture
User
32 posts

hello there i am getting E5 for device id. but when i am trying to read accelometer x data. i am also getting E5.

Attachments: 
user_1377889's picture
User
9590 posts

You do not send dummy bytes to get x values. Aren't the values 16 bit wide? You'll have to combine two bytes to form a 16 byte int.

 

Bob

rushin010's picture
User
32 posts

yes i need 10 byte. then how many dummy byte should i send??

Log in to post new comments.