I'm having trouble interfacing an ADXL375 accelerometer (almost the same as the more widely used ADXL345 from what I can tell). I would appreciate any help!
The datasheet for the ADXL375 is here:
http://www.analog.com/media/en/techn...ts/ADXL375.pdf
I have it connected to a 16F676 with 1k resistors connecting the ADXL375's DQI (input) and DQO (output) pins to the pic. CLK and CS are direct connection to the pic with the ADXL375's two interrupt pins left floating. I'm using a 3.3v regulator.
I'm trying to interface with it in SPI mode (which is the default if I've read the datasheet correctly). However, all I get are "0-0-0" lines in the terminal. Any suggestions?
Thanks in advance for any help!
Code:@ device pic16F676, hs_osc, wdt_off, pwrt_off, mclr_off, protect_off cmcon=7 define osc 8 ANSEL = %00000000 'AN0 through AN7 are digital AX1 VAR WORD 'X-dir accel AY1 VAR WORD 'Y-dir accel AZ1 VAR WORD 'Z-dir accel wconfig var byte 'ADXL FIFO address write byte rconfig var byte 'ADXL FIFO address read byte 'temporary shiftout bytes ACDATA1 var byte ACDATA2 var byte ACDATA3 var byte ACDATA4 var byte ACDATA5 var byte ACDATA6 var byte CS var PORTa.2 ' CHIP SELECT SDO var PORTc.0 ' DATA OUT FOR ADXL375 SDI var PORTc.1 ' DATA IN FOR ADXL375 CLK var PORTc.2 ' CLOCK PIN LED var PORTc.4 ' LED PIN rconfig=50 'first FIFO address register where acceleration values are stored rconfig.7=1 'change bit7 to 1 to indicate a read operation rconfig.6=1 'change bit6 to 1 to indicate multiple bytes will be read 'write address for the power_ctl byte with bit7=0 (write operation) and bit6=0 (1 byte operation) wconfig=45 'blink to verify program is running high LED pause 100 low LED pause 100 high LED high CS pause 1 loop: low CS pause 1 shiftout SDI,CLK,1,[wconfig\8,%00001000\8] 'write 1 to bit3 of power_ctl register to put ADXL375 in measurement mode high CS pause 1 low CS shiftout SDI,CLK,1,[rconfig\8] 'shiftout read command and FIFO address shiftin SDO,CLK,1,[ACDATA1,ACDATA2,ACDATA3,ACDATA4,ACDATA5,ACDATA6] 'shiftin acceleration values high CS AX1.highbyte=ACDATA1 AX1.lowbyte=ACDATA2 AY1.highbyte=ACDATA3 AY1.lowbyte=ACDATA4 AZ1.highbyte=ACDATA5 AZ1.lowbyte=ACDATA6 serout2 portc.5,16468,[DEC AX1,"-",DEC AY1,"-",DEC AZ1,10,13] pause 1000 goto loop end




Bookmarks