⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
3 posts / 0 new
Last post
Lora
Offline
Last seen:3 years 3 months ago
Joined:2016-12-05 10:29
i2c example not working

Dear Dialog,

I am using the i2c_eeprom project from peripheral_examples and i want to read the values from tmp102 sensor, but my program it either blocked in WAIT_UNTIL_I2C_FIFO_IS_EMPTY() inside i2c_init() function
and if i comment the WAIT_UNTIL_I2C_FIFO_IS_EMPTY() , is blocked in WAIT_FOR_RECEIVED_BYTE() inside i2c_eeprom_read_byte() function.

(I have already tested the sensor in Arduino Uno and i was able to receive the data.)
I connected SDA and SCL to the P0_3 and PO_2 pins .Do i need to connect something else?
Removed J26 jumpers.
In user_periph_setup.h i defined
#define I2C_EEPROM_SIZE 0x20000
#define I2C_EEPROM_PAGE 256
#define I2C_SLAVE_ADDRESS 0x48
#define I2C_SPEED_MODE I2C_FAST
#define I2C_ADDRESS_MODE I2C_7BIT_ADDR
#define I2C_ADDRESS_SIZE I2C_1BYTE_ADDR
#define I2C_GPIO_PORT GPIO_PORT_0
#define I2C_SCL_PIN GPIO_PIN_2
#define I2C_SDA_PIN GPIO_PIN_3

In user_periph_setup.c inside GPIO_reservations() i added
RESERVE_GPIO(I2C_SCL, I2C_GPIO_PORT, I2C_SCL_PIN, PID_I2C_SCL);
RESERVE_GPIO(I2C_SDA, I2C_GPIO_PORT, I2C_SDA_PIN, PID_I2C_SDA);
and in set_pad_functions() ,
GPIO_ConfigurePin(I2C_GPIO_PORT, I2C_SCL_PIN, INPUT, PID_I2C_SCL, false);
GPIO_ConfigurePin(I2C_GPIO_PORT, I2C_SDA_PIN, INPUT, PID_I2C_SDA, false);
And in main() i called the I2C EEPROM test suite, but every test stops at WAIT_FOR_RECEIVED_BYTE() in a read command or WAIT_UNTIL_I2C_FIFO_IS_EMPTY() in a write command.

I tried different address ,pin , but i still cannot obtain the sensor’s value.
If you could tell me what i am doing wrong , it would help a lot.
Thanks in advance

Device:
MT_dialog
Offline
Last seen:3 months 14 hours ago
Staff
Joined:2015-06-08 11:34
Hi Lora,

Hi Lora,

The i2c example is a demonstartion in order to be used for interacting with an eeprom you dont need a size or a page in case you would like to interact with a sensor. You wont be able to communicate with the sensor you would like by running the example as is, on a different I2C module (if that is what you are trying to do). You will have to modify the code in order to suit the sensor that you are using, or better take the eeprom example as a reference and based on that create something simpler in order to interact with the temperature module. The fact that the device stucks in the WAIT_FOR_RECEIVED_BYTE() means that the i2c module never got any data from the temperature sensor and the WAIT_UNTIL_I2C_FIFO_IS_EMPTY() means that when you are writing, the data are never send to the other side and stays in the FIFO of the device because apparently the I2C line is busy. Also you need to use pullups on your I2C communication on both lines, and i see that you are not using the internal pull ups, are you using external pull ups ?

Thanks MT_dialog

z0806020433
Offline
Last seen:1 year 14 hours ago
Joined:2016-05-05 13:32
Hi Lora!

Hi Lora!
have you deal with the problem ? i get the same problem.