- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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??
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok thanks for your support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
...and your latest project state?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks for your support. its working. actually i had made mistake in pin assignment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes i need 10 byte. then how many dummy byte should i send??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i have some question. like if i want to on adxl345, i have to write 0x08 in 0x32 . so i write SPIM_WriteTxData two times.then it is necessary to write dummy bytes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In SPI you get back exactly one byte for every byte you send.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok then why dummy byte required?? if i send 0x32 then i should get value from 0x32
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you send the first bit of your 0x32 the device does not yet know what you intend to do, but with every bit you send, at the very same time a bit is answered. So you get a dummy byte back at first. As a matter of fact you do not really "Read" from an SPI device, all communication happens bi-directionally at the same time. I would suggest you to read SPI datasheet and / or google for it. They can explain better than I can.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes i have read datasheet. but i had confusions. in most of datasheet they explain with shift register
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
now can you please tell me that when i want to read, should i send dummy byte??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
in last project, i have commented dummy byte. after uncommenting it, i am getting 0xE5 as x value. i have also used SPIM_ClearRxBuffer();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi mr rushin010.could u runing adxl345 with spi or not?because i cant volved this problem!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Moro,
Could you share the working and tested project of ADXL345 with SPI or I2C in Psoc4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your read routine has an error:
For every byte the SPI interface gets, one byte is returned immediately. When the very first byte is sent, the interface does not "know" yet what to answer, so a dummy byte is returned which should be skipped. This you do.
SPI has no read command, so you must send dummy bytes to retrieve the information wanted. This you do not!
Bob