STM32F4 I2C reading EagleTree Sensor problem
Posted: Mon Oct 22, 2012 5:59 am
Greetings
With a little shame I come here asking for assistance. I was trying to read Altimeter V3 and Airspeed V3[1] sensors from Eagletree, which have a I2C bus to acquire its raw data. Eagletree provides information on how to use this sensors, the I2C addresses and pseudocode to access it[2]. Even with all this information I have been unsuccessful to read this sensors, even though my I2C bus has already been tested to work with an I2C compass. The I2C never returns an error (the I2C adress seems to be right) but no data is returned.
This is my code (first initial Driver Parameters, then the reading code)
The manual instructions are this:
And other user do basically the same thing:
I don't know if I am not using the writing/reading commands well, but I have tried a number of configurations, from only reading to write/read, but in oscilloscope the bus is asserted to low and the clock is running.
I would appreciate any comment or suggestion
OFF TOPIC NOTE: I also tried to use Float support in chprintf, and this crashed all the system. From the point where I try to flash the MCU, errors happen, to the point that st-link is unavailable to reset the MCU to flash it and you must do it by hand. I don't know the cause, some variable size error? but I just wanted to warn other people thinking of doing this or any workaround this subject.
[1] http://www.eagletreesystems.com/support ... eed-v3.pdf
[2] http://www.eagletreesystems.com/support ... or-i2c.pdf
With a little shame I come here asking for assistance. I was trying to read Altimeter V3 and Airspeed V3[1] sensors from Eagletree, which have a I2C bus to acquire its raw data. Eagletree provides information on how to use this sensors, the I2C addresses and pseudocode to access it[2]. Even with all this information I have been unsuccessful to read this sensors, even though my I2C bus has already been tested to work with an I2C compass. The I2C never returns an error (the I2C adress seems to be right) but no data is returned.
This is my code (first initial Driver Parameters, then the reading code)
Code: Select all
/*
* I2C Configuration
*/
static const I2CConfig i2c1cfg = {
OPMODE_I2C,
100000,
STD_DUTY_CYCLE
};Code: Select all
i2cStart(&I2CD1, &i2c1cfg);
uint8_t addra = 0x75;
uint8_t regAddra[] = {0x07};
uint8_t rxdata[] = {0, 0};
status = i2cMasterTransmitTimeout(&I2CD1, addra, regAddr, 1, rxdata, 2 , 100);
if (status != RDY_OK){
errors = i2cGetErrors(&I2CD1);
chprintf((BaseSequentialStream *)&SD5, "error 2 %U - %U", status==RDY_TIMEOUT, errors);
}
The manual instructions are this:
Code: Select all
}
byte data[2];
signed short reading = 0xFFFF;
i2c_start();
// select sensor in write mode
if (!(i2c_write(SENSOR_ADDRESS | I2C_WRITE_BIT))) {
// send "read data" command to sensor
if (!i2c_write(0x07)) {
i2c_restart(); // perform I2C restart
// select sensor in read mode
if (!i2c_write(| SENSOR_ADDRESS | I2C_READ_BIT)) {
// read two bytes of sensor data
data[0] = i2c_read(1);
data[1] = i2c_read(0);
reading = *((signed short *)(&data[0]));}
}
}
i2c_stop();
And other user do basically the same thing:
Code: Select all
START (set the start condition in your TWC)
out: 0xE8
out: 0x07
RESTART (set RESTART in TWC)
out: 0xE9
READ (set the rx enable in TWC)
save the rx register as your first data byte
ACK (set the ACK bit in your TWC)
READ (flip the receive enable bit in control register again)
save the rx register as your second data byte
STOPI don't know if I am not using the writing/reading commands well, but I have tried a number of configurations, from only reading to write/read, but in oscilloscope the bus is asserted to low and the clock is running.
I would appreciate any comment or suggestion
OFF TOPIC NOTE: I also tried to use Float support in chprintf, and this crashed all the system. From the point where I try to flash the MCU, errors happen, to the point that st-link is unavailable to reset the MCU to flash it and you must do it by hand. I don't know the cause, some variable size error? but I just wanted to warn other people thinking of doing this or any workaround this subject.
[1] http://www.eagletreesystems.com/support ... eed-v3.pdf
[2] http://www.eagletreesystems.com/support ... or-i2c.pdf