I am using AT32UC3C microcontroller which has 64 pins. I am using gpio pin PB01 as SCK and gpio pin PA04 as SDA and ticking then manually high and low. These pins are configured as GPIO_OPEN_DRAIN and GPIO_DIR_OUTPUT. I have connected this controller to MPU9150 sensor connecting pin PB01 to SCK and PA04 to SDA of the sensor.What I observed on oscilloscope is when I read accelerometer values from MPU9150 the SDA line high voltage is 3.3V and low voltage is 0.24V. But when I see the voltage on SDA line while accessing magnetometer of MPU9150 the lower value goes up to 1.68V. The sensor is sending data and acknowledging to microcontroller but microcontroller doesn't treat 1.68V as logic low. So all register values are read as 1. Can I solve the problem without changing the hardware? I mean if I define a new threshold value for logic high and logic low level and say that if voltage is above 2V consider it logic high else logic low. Is it possible.
The datasheet of AT32UC3C says:
PIN__GPIO__PIN TYPE_______GPIO FUNCTION
A B C
Can I use Analog comparators to compare the value of this pin to some other pin whose voltage is 2V and instead of reading digital gpio value I assign 0 when voltage is below 2V and 1 if voltage is above 2V.
Or is my configuration wrong. Can I used open drain mode for gpio pins with dir_output mode? If my configuraton is wrong what should be the correct configuration.
Or is there any other way to solve the problem? Please tell me if you need any other information. Thanks in advance.
I would like to share 1 more fact. When I read acc and gyro, Auxiliary SDA and Primary SDA as well as Auxiliary SCL and Primary SCL read exactly the same voltage levels.(seen on oscilloscope). But when I read magnetometer, Auxiliary SCL and Primary SCL read the same but Auxiliary SDA and Primary SDA has a difference.When I see Auxiliary SDA, I can find that voltage toggles between 3.3V to 0.6V(MPU9150 is able to pull down volatge to 0.6V) but when I see primary SDA, voltage toggles between 3.3V to 1.68V. Auxiliary SDA and SCL pins are left open(not connected anywhere in my circuit) whereas communication is done vis Primary SDA and SCL lines.
I would also like to add something about MPU9150 sensor.It is actually a combination of 2 sensors MPU6050(acc and gyro) and AK8975(magnetometer). SDA and SCL of MPU6050 are connected to primary SDA and SCL while SDA and SCL of AK8975 are connected to auxiliary SDA and SCL of MPU9150. AK8975 can be accesses by 2 methods. First is bypass enable method,where Primary and Auxiliary SDA gets shorted. Second is Master mode of MPU9150 where MPU9150 is master to sensors connected on Auxiliary SCL and SDA i.e. even to AK8975. I am using method 1 right now and what I have mentioned in above paragraphs are problems faced by me in method 1. I have still not implemented method 2.