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.

CCS/TM4C123GH6PM: TM4C123GH6PM+adxl345+energia

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: ENERGIA

Tool/software: Code Composer Studio

Hello ,

I have been using TIVA +adxl345  using energia .I was not able get the value on the serial monitor . If any one worked please mention any changes need to made in the code

#include<Wire.h>

#define device (0x53)

//#define POWER_CTL Ox2D
byte buff[6];
char POWER_CTL = 0x2D; //Power Control Register
char DATA_FORMAT = 0x31;
char DATAX0 = 0x32; //X-Axis Data 0
char DATAX1 = 0x33; //X-Axis Data 1
char DATAY0 = 0x34; //Y-Axis Data 0
char DATAY1 = 0x35; //Y-Axis Data 1
char DATAZ0 = 0x36; //Z-Axis Data 0
char DATAZ1 = 0x37; //Z-Axis Data 1

void setup()
{
// put your setup code here, to run once:
Wire.begin();
Serial.begin(9600);
writeTo(DATA_FORMAT,0x01);
writeTo(POWER_CTL,0x08);

}

void loop()
{
// put your main code here, to run repeatedly:
readaccl();
delay(500);

}

void readaccl()
{
uint8_t bytetoread=6;
readfrom( DATA_FORMAT, bytetoread , buff);
int x=((int ) buff[1] <<8)| buff[0];
int y=((int ) buff[3] <<8)| buff[2];
int z=((int ) buff[5] <<8)| buff[4];

Serial.print("x :");
Serial.print(x);
Serial.print("y :");
Serial.print(y);
Serial.print("z :");
Serial.print(z);


}

void writeTo(byte addr,byte value)
{
Wire.beginTransmission(device);
Wire.write(addr);
Wire.write(value);
Wire.endTransmission();



}

void readfrom(byte addr,int num,byte buff[])
{
Wire.beginTransmission(device);
Wire.write(addr);
Wire.endTransmission();

Wire.beginTransmission(device);
Wire.requestFrom(device,num);
int i=0;


while(Wire.available())
{
buff[i]=Wire.read();
i++;

}
// Wire.endTransmission();

}

  • Hi Ganesh,

      Unfortunately, we do not support Energia in this forum. For Energia support please post your questions to https://forum.43oh.com/forum/119-energia/

      With that said, I can offer some general troubleshooting tips. 

      - Have you run any existing Energia examples that use the serial monitor? If these examples are working then you can compare you code with the examples.

      - Do you have the matching baud rate and config (# of stop bits, parity and char length) between the two sides?

      - On your PC, go to the device manager and have you found the Virtual COM port enumerated for the TM4C device? On your PC terminal window, did you specify the corresponding COM port?

  • Hi Charles,

    Unless 'cb1 staff' here is mistaken - the great bulk of poster's code appears as 'Arduino Code!'    Has the (pardon) Energy-Lite group recommended 'unmodified Arduino Code' - for direct usage by TM4C (ARM) users?