AnsweredAssumed Answered

help reading adxl312 (spi 4 wire)

Question asked by pranavp on Jul 31, 2011
Latest reply on Aug 1, 2011 by AndyR
hi,

i am having trouble reading acceleration data from adxl312, this  accelerometer can be read/write similar to adxl345.
below is my code, it doesn't work,  no matter how much i shake it i get only 0 reading. i would really  appreciate any help..
i am working with picbasic/pic18f4550

thanks

include "modedefs.bas" DEFINE OSC 48 rx var porta.3 tx var porta.4 data_in var porta.5 data_out var porte.0 CLOCK var porte.1 cs var porte.2 adxl_data_x0 var word adxl_data_x1 var word pause 100 high CS SEROUT tx,T9600,["ADXL 312 Test...",10]     high CLOCK     low cs     shiftout data_out, CLOCK, 2, [%0011000100100000]     high cs      high CLOCK     low cs     shiftout data_out, CLOCK, 2, [%0010111010000000]     high cs              high CLOCK     low cs     shiftout data_out, CLOCK, 2, [%0010111100000000]     high cs     high CLOCK     low cs     shiftout data_out, CLOCK, 2, [%0010110000001010]     high cs     high CLOCK     low cs     shiftout data_out, CLOCK, 2, [%0010110100001000]     high cs     main:     pause 10            high CLOCK     low cs     shiftout data_out, CLOCK, 2, [%10110011]     shiftin data_in, CLOCK, 6, [adxl_data_x1\13]     high CS     high CLOCK     low cs     shiftout data_out, CLOCK, 2, [%10110010]     shiftin data_in, CLOCK, 6, [adxl_data_x0\13]     high CS               SEROUT tx,T9600,["START",10]     SEROUT tx,T9600,[#adxl_data_x0,10]     SEROUT tx,T9600,[#adxl_data_x1,10]     SEROUT tx,T9600,["END",10] goto main

Outcomes