SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By ks190995
#182855
I was able to access magnetometer using primary SDA and SCL lines using arduino and sparkfun's MPU9150 breakout board.
Now I am using AT32UC3C2512C microcontroller and MPU9150 and embedding it on a custom made board with same schematic as sparkfun board(just difference of pull up resistors). Just some extra sensors are provided such as pressure sensor, data flash.

I am not using dedicated TWI pins of microcontroller. I am using portA pin 4 for primary SDA and portB pin 1 for SCL. These are gpio pins. I am ticking clock manually(Using software TWI/I2C). Gpio pins are configured to be in open drain and directional output mode.

Here I am able to access accelerometer and gyroscope values but not magnetometer. I am not able to access magnetometer of it from primary SDA and SCL lines. When I saw the pulses on an oscilloscope I found out something strange. Firstly I checked the auxiliary lines and then I checked primary lines. Primary SDA and SCL are connected to 3.3V via 4.7kOhm resistors.Which implies that VLOGIC = 3.3V = VDD. Auxiliary SDA and SCL are left unconnected.
The commands that I have included in initialization are:
// Wake up the devices and set the x-axis gyroscope as the reference oscillator
single_byte_write(0x6B,0x01);

// Set the bandwidth of the sensors to 260/256 Hz.
single_byte_write(0x1A,0x00);

// Set the accelerometer scale ranges to max (+-16g) (FS_SEL=3)
single_byte_write(0x1C,0x18);

// Set the gyroscope scale ranges to max (+-2000 deg/s) (AFS_SEL=3)
single_byte_write(0x1B,0x18);

// Bypass mode of MPU9150 enable
single_byte_write(0x37,0x02);

//Master mode of MPU9150 disable
single_byte_write(0x6A,0x00);

The commands that I have included in while loop which runs indefinitely are:

single_byte_write_magnetometer(0x0A,0x01); //Sets Single measurement mode

delay(8); //Wait for 8ms for data to be ready(data gets ready to be read from magnetometer) // I have checked the desired register for data ready and it shows 1.(not including that command here)

single_byte_read_magnetometer(0x03,mag);//Reading this register and storing value in an array called mag

**************************************************************************************************************************************************
The output that I see is attached. Please have a look at it.

After having a look at images :
I again mention that in my connections Auxiliary SDA and SCL are kept open. I am accessing magnetometer directly via primary SDA and SCL lines. Also most importantly, I am able to access acceleometer, gyroscope and temperature registers via the SDA and SCL lines. On observing that data on oscilloscope I found that SCL toggles between 0.84V to 3.28V while SDA toggles between 0V to 3.28V. So microcontroller has no problem in deciding the logic level.

How should I correct this problem?
You do not have the required permissions to view the files attached to this post.