⚠️
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.
6 posts / 0 new
Last post
johncharris
Offline
Last seen:1 year 8 months ago
Joined:2018-07-16 17:12
I2C Not Working.

I'm trying to get the da14580 to connect to a HP203b pressure sensor. I have tested this sensor on a Raspberry Pi and it works fine. On the da14580 the timing seems to be too fast. I can see the signal gets sent but the pressure sensor doesn't respond. This is running at normal speed. When I look at the wave form in a Logic Analyzer, the Pi connection SCL is low for 10 uSeconds then high for 10 uSeconds as expected. With the dialog chip, it is low for 6 uSeconds and high for 4.5 u Seconds. (I am guessing that is actaully 5 and 5, with some error from my sampling speed)

Why would the SCL rate be twice as fast coming from the da14580 chip. What can I do to fix this?

Thank you

John

Device:
PM_Dialog
Offline
Last seen:2 days 11 hours ago
Staff
Joined:2018-02-08 11:03
Hi johncharris,

Hi johncharris,

Can you please provide me the initialization cod snippet of the I2C peripheral block? In addition, if you were able to share me wave forms from the logic Analyzer, it would be very helpful.

Thanks, PM_Dialog

johncharris
Offline
Last seen:1 year 8 months ago
Joined:2018-07-16 17:12
user_i2c_init(0x76, I2C_7BIT
user_i2c_init(0x76, I2C_7BIT_ADDR, I2C_STANDARD, I2C_1BYTE_REGISTER, I2C_2BYTES_ADDR);
void user_i2c_init(uint16_t slave_address, I2C_ADDRESS_MODES i2c_address_width, I2C_SPEED_MODES bit_rate, I2C_REGISTER_WIDTH register_width, I2C_ADDRESS_BYTES_COUNT register_address_width) { // Save the settings in a struct i2c_cfg_env.i2c_address_width = i2c_address_width; i2c_cfg_env.bit_rate = bit_rate; i2c_cfg_env.register_width = register_width; i2c_cfg_env.register_address_width = register_address_width; // Initialize the I2C with the address provided as argument SetBits16(CLK_PER_REG, I2C_ENABLE, 1); // Enable clock for I2C SetWord16(I2C_ENABLE_REG, 0x0); // Disable the I2C controller SetWord16(I2C_CON_REG, I2C_MASTER_MODE | I2C_SLAVE_DISABLE | I2C_RESTART_EN); // Slave is disabled SetBits16(I2C_CON_REG, I2C_SPEED, i2c_cfg_env.bit_rate); // Set speed. Standard speed = 1, fast = 2 if (i2c_cfg_env.i2c_address_width == I2C_7BIT_ADDR) { SetBits16(I2C_CON_REG, I2C_10BITADDR_MASTER, 0); // Set addressing mode. 7bit = 0 } else { SetBits16(I2C_CON_REG, I2C_10BITADDR_MASTER, 1); // Set addressing mode. 10bit= 1 } SetWord16(I2C_TAR_REG, slave_address & 0x3FF); // Set Slave device address SetWord16(I2C_ENABLE_REG, 0x1); // Enable the I2C controller while (GetWord16(I2C_STATUS_REG) & 0x20) ; // Wait for I2C master FSM to be IDLE }

Here is the code. I have the full I2C c file I'm using in the attached zip. I have a screenshot of the logic analyzer with a working implementation on a Raspberry Pi and another screenshot of the non working waveform from the da14580.

Thank you,

John

Attachment:
PM_Dialog
Offline
Last seen:2 days 11 hours ago
Staff
Joined:2018-02-08 11:03
Hi John,

Hi John,

Let me check your inputs and I will get back to you as soon as possible.

Thanks, PM_Dialog

johncharris
Offline
Last seen:1 year 8 months ago
Joined:2018-07-16 17:12
Thank you, John

Thank you,

John

PM_Dialog
Offline
Last seen:2 days 11 hours ago
Staff
Joined:2018-02-08 11:03
Hi John,

Hi John,

The I2C block can operate in two modes: either in Normal or in Fast mode. The I2C_SPEED bitfield of the I2C_CON_REG register controls at which speed the controller operates.

  • 1= standard mode (100 kbit/s)
  • 2= fast mode (400 kbit/s)

根据你的初始化代码,标准的密苏里州de in used, so the speed will be at 100 kbit/s, as you can see in the logic analyzer wave form. I tested it in my side and in standard mode the SCL is at 1(high) for 4.908 usec and in 0(low) for 5.092usec, which means 10usec period time. In your case you need 20usec (10usec at high, 10usec at low) which is translated to 50 kbit/s. This is not possible to be achieved as the minimum speed for I2C block is at 100 kbit/s.

Since there is no generic i2c driver in order to create you own sensor driver implementation, I would suggest you to have as reference the I2C example of the SDK which is located under 5.0.4\projects\target_apps\peripheral_examples\i2c\i2c_eeprom path. For example, check the i2c_eeprom_init() function.

Thanks, PM_Dialog