ADXL345 Bad Response? - Raspberry Pi Forums
i'm using propriety board made analog devices not chinese one.
it's connected pi per rbpi2 adxl345.jpg attached.
i'm running this
code: select all
#include <bcm2835.h> #include <stdio.h> int main(int argc, char **argv) { if (!bcm2835_init()) return 1; bcm2835_spi_begin(); bcm2835_spi_setbitorder(bcm2835_spi_bit_order_msbfirst); // default bcm2835_spi_setdatamode(bcm2835_spi_mode0); // default bcm2835_spi_setclockdivider(bcm2835_spi_clock_divider_65536); // default bcm2835_spi_chipselect(bcm2835_spi_cs0); // default bcm2835_spi_setchipselectpolarity(bcm2835_spi_cs0, low); // default char buf[] = { 0x80, 0x00, 0x00, 0x00}; // read deviceid of adxl345 bcm2835_spi_transfern(buf, sizeof(buf)); // buf filled data read slave printf("device id: %02x %02x %02x %02x \n", buf[0], buf[1], buf[2], buf[3]); // delay(1000); char buf2[] = { 0x2d, 0x02, 0x00}; // setup 0x2d ( power_ctl reg ) measure bcm2835_spi_transfern(buf2, sizeof(buf2)); // (b7 reset == write) printf("setup response is: %02x %02x %02x %02x \n", buf2[3], buf2[2], buf2[1]); delay(1000); char buf3[] = { 0xb2, 0x00, 0x00}; // read x0 reg 0x32 (b7 set == read) bcm2835_spi_transfern(buf3, sizeof(buf3)); printf("x axis is: %02x %02x %02x \n", buf3[3], buf3[2], buf3[1]); // delay(1000); bcm2835_spi_end(); return 0; }
code: select all
~/projects/adxl $ sudo ./spix device id: 00 00 00 00 setup response is: f2 f2 f2 f2 x axia is: 00 00 00
same idea setup response.
2 attached oscillograms confirm responses get.... edit: cannot attach 64kb max makes them small view.
these f2 responses error code?
any appreciated here.
have faulty unit or code bad somewhere?
have faulty unit or code bad somewhere?
raspberrypi
Comments
Post a Comment