MXC6655XA Digital Three-Axis Accelerometer

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
mikikimi
Posts: 13
Joined: 25 Nov 2020 17:29

MXC6655XA Digital Three-Axis Accelerometer

#1 Post by mikikimi » 29 Jun 2021 09:17

Hello , i have a problem with reading values from MXC6655XA. I am using Pic16f1825, and address of sensor is 0x15. My writing function is working, but reading not. What can be the problem?
Thanks
This is how i wrote my initialization and functions:

OSCCON=0x72; // set oscillator to 8MHz
ANSELA=0;
ANSELC=0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
I2C1_Init(400000); // initialize I2C communication

My functions :

void write(unsigned short address,unsigned short w_data)
{
I2C1_Start(); // issue I2C start signal
//address 0x15
I2C1_Wr(0x2A); // address sensor +W
I2C1_Wr(address);
I2C1_Wr(w_data);
I2C1_Stop(); // issue I2C stop signal
}

unsigned short read(unsigned short address)
{
short int read_data;

I2C1_Start();
I2C1_Wr(0x2A); //address sensor +W
I2C1_Wr(address);
I2C1_Start();
I2C1_Wr(0x2B); //address sensor +R
read_data=I2C1_Rd(0); // I THINK THIS LINE IS A PROBLEM
I2C1_Stop();

return(read_data);

}

mikikimi
Posts: 13
Joined: 25 Nov 2020 17:29

Re: MXC6655XA Digital Three-Axis Accelerometer

#2 Post by mikikimi » 02 Jul 2021 08:42

PROBLEM SOLVED :D

Domingo
Posts: 1
Joined: 21 Apr 2022 01:57

Re: MXC6655XA Digital Three-Axis Accelerometer

#3 Post by Domingo » 21 Apr 2022 02:04

Hi Mikikimi,
Can you share how you got it to work? I having the same problem, I am sending 0x2A, 0X0F, 0X2B to read the "Who Am I" register and getting back 0xFF.
Thanks

Post Reply

Return to “mikroC PRO for PIC General”