This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430G2553 and ADXL345 SPI

Other Parts Discussed in Thread: MSP430G2553, ENERGIA

Hi there, 

I've had my launch pad for about a week now and I've been able to flash lights and all those sorts of things. Now I am trying to use the SPI perpherial to interface the MSP430G2553 chip with an Analog Devices ADXL345 accelerometer. 

I have been through the sample code provided in the wiki plus many other versions I have found and have just about got my head around how to set some functions up to work. I have also tried the Energia software and SPI examples included. This helped a lot and I finially managed to get some sort of data flowing. But I'm pretty sure it was all nonsense and the Energia environment is too basic to help debug so I've been trying to put together the semi working code from the Energia example and some other examples in a Code Composer Studio Project. 

I seam to be able to transmit some information as I can see it on the oscilloscope (whether or not it is correct I'm not sure) but the code gets stuck in a while loop after transmission when it is waiting for a response and I don't know why as it seamed to work when it was within the Energia example. All I am trying to do at the moment is get the device ID so I know the correct information is being sent and received. 

Could anyone offer some advise on this? I don't really know what to try next.

I've attached my main.c file for viewing.

6011.main.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//Include Files
#include "msp430g2553.h"
#include <stdint.h>
//ADXL345 Register Addresses
#define DEVID 0x00 //Device ID Register
#define THRESH_TAP 0x1D //Tap Threshold
#define OFSX 0x1E //X-axis offset
#define OFSY 0x1F //Y-axis offset
#define OFSZ 0x20 //Z-axis offset
#define DURATION 0x21 //Tap Duration
#define LATENT 0x22 //Tap latency
#define WINDOW 0x23 //Tap window
#define THRESH_ACT 0x24 //Activity Threshold
#define THRESH_INACT 0x25 //Inactivity Threshold
#define TIME_INACT 0x26 //Inactivity Time
#define ACT_INACT_CTL 0x27 //Axis enable control for activity and inactivity detection
#define THRESH_FF 0x28 //free-fall threshold
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Thanks, 

Alex

**Attention** This is a public forum