How can I use i2c in BCM20737S?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi all

I intend to use MCP9808 (i2c temperature sensor).

http://www.farnell.com/datasheets/1522173.pdf

So, I wrote codes like below.

==================in Constants========================

// Read operation to the lower level driver is 0.

#define I2C_SLAVE_OPERATION_READ         (0)

// Write operation to the lower level driver is 1.

#define I2C_SLAVE_OPERATION_WRITE        (1)

#define MCP9808_SLAVE_ADDRESS (0x18 << 1)

===================================================

==============in timer_1s()============================

UINT16 data = 0;

temperature_sensor_read_16_bit_register(0x05, &data);

===================================================

However,

cfa_bsc_Opextended in temperature_sensor_read_16_bit_register always returns CFA_BSC_STATUS_NO_ACK.

I edited a part of temperature_sensor_read_16_bit_register like following:

read_status = cfa_bsc_OpExtended(reg_bytes_to_read, sizeof(reg_bytes_to_read), reg_read_bytes_to_write,

    sizeof(reg_read_bytes_to_write), MCP9808_SLAVE_ADDRESS, I2C_SLAVE_OPERATION_READ);

Why do these code work correctly?

Is there anyone who could make temperature_sensor_read_16_bit_register work correctly?

Please tell me what to do.

Sincerely,

Ishikawa.

0 Likes
1 Solution
Anonymous
Not applicable

Hi, arvinds and j.t.

I'm sorry for my late reply.

I could confirm that i2c function which I implemented works correctly by using my self made board and the same code. However, I couldn't identify the cause of the problem....I apologize.

I'd like to express my deepest appreciation for your help and support, arvinds and j.t.

View solution in original post

0 Likes
15 Replies
Anonymous
Not applicable

Hello Ishikawa,

Broadcom provides a sample code set for attaching several different sensors to the BCM20737:

WICED Sense Kit using SDK 2.2:

These examples should provide you with connecting sensors to the I2C bus.

Thanks

JT

0 Likes
MichaelF_56
Moderator
Moderator
Moderator
250 sign-ins 25 comments on blog 10 comments on blog

Have you taken a look at the i2c_temperature_sensor sample application within the SDK?

Leveraging the well known LM73 Temperature Sensor from National (now TI), this example provides a proven example showing how to read/write data from/to the LM73, along with the handling of ALERT interrupts from the sensor.

Also, keep in mind that alot of customers struggle with the slave addressing when first implementing a new/custon I2C sensor of their own.

For this, the developers have recommended that you try tracing the I2C lines on an oscope or a logic analyzer to see if the right address is on the bus and the slave is acking it.

This thread contains this advice and some other excellent I2C debug information: how can i use to i2c between bmi160 sensor and BCM20732?

dmiya

0 Likes
Anonymous
Not applicable

Please check your schematic first.

Are all A0-A2 tied to GND?

What is the voltage supplying to MCP9808?

The operating voltage is 2.7 to 5.5V.

0 Likes
Anonymous
Not applicable

dmiya, j.t, mwf_mmfae

Thank you for responding!

>The operating voltage is 2.7 to 5.5V.

I'm so sorry that I didn't check the voltage of VDDIO of I2C of evaluation board....

The voltage of this pin is 1.8V.I assumed that the voltage of this pin is 3.3V.

I sincerely apologize.


Well, I want to resolve this problem.

Can I edit the voltage by changing the resistances named RFB1, RFB2 and C22 in Hardware User Guide (SDK 2.x and TAG3 Board)?




0 Likes

A voltage divider is required.

0 Likes
Anonymous
Not applicable

Hi all

I checked the signal I2C bus by using Oscilloscope.

Why does the cycle of i2c is 10us (SCL is purple)?

Is the frequency of cfa_xx functions 400kHz isn't it? (The cycle of SCL shoud be 2.5us, shouldn't it?)

Furthermore, SDA which is yellow signal sends 0b10100000 at the first although I wrote codes as following:

>read_status = cfa_bsc_OpExtended(reg_bytes_to_read, sizeof(reg_bytes_to_read), reg_read_bytes_to_write,

    sizeof(reg_read_bytes_to_write), MCP9808_SLAVE_ADDRESS, I2C_SLAVE_OPERATION_READ);

>#define MCP9808_SLAVE_ADDRESS (0x18 << 1)

>#define I2C_SLAVE_OPERATION_READ         (0)

In this case, should 0b00110000 be sent, shouldn't it?

Please tell me how to resolve this problem.

IMG_3188.JPG

0 Likes

1/Time = Freq

1/Freq = Time

1/400,000 (400K) = .0000025, or 2.5us

I believe 10us is closer to 100K

I will need to speak with the team about how we should go about helping with the troubleshooting of your I2C interface to your external processor.

0 Likes
Anonymous
Not applicable

Hi mwf_mmfae

Thank you for your response.

>I will need to speak with the team about how we should go about helping with the troubleshooting of your I2C interface to your external processor.

I have not resolved this problem yet.

So, I have been waiting to hear from you.

I'm sorry to cause you problem.

Sincerely,

Ishikawa.

0 Likes

0b10100000 = 0xA0. This is the address of the I2C EEPROM in the module. The initial access to the EEPROM always occurs at 100KHz, so the 10uS you see is expected. So the trace here is not of the app accessing the temperature sensor. Can you try capturing that?

0 Likes
Anonymous
Not applicable

Hi arvinds

Thank you for your advice.

>This is the address of the I2C EEPROM in the module. The initial access to the EEPROM always occurs at 100KHz, so the 10uS you see is expected. So the trace here is not of the app accessing the temperature sensor. Can you try capturing that?

OK. I see. I will try to capture the app accessing the temperature sensor signal.

However, I have two questions about this.

The questions are about this sentence : >The initial access to the EEPROM always occurs at 100KHz, so the 10uS you see is expected.

Does the signal to access to EEPROM appear every the i2c connection (write and read)? Although I captured the signal of i2c when I called temperature_sensor_read_16_bit_register function of i2c_temperature_sensor sample many times, the signal of initial access to the EEPROM appears.

If your answer is no, why does initial access signal appear whenever I call temperature_sensor_read_16_bit_register function?


The last one is relevant above question.

When should the signal of app accessing temperature sensor I use appear ?

If there are some mistakes in English, I'd like to apologize.

0 Likes

> Does the signal to access to EEPROM appear every the i2c connection (write and read)?

No.

> If your answer is no, why does initial access signal appear whenever I call temperature_sensor_read_16_bit_register function?

Is the app crashing? Can you check if the application's create function is called again about 4s after you attempt to read the I2C sensor?

0 Likes
Anonymous
Not applicable

>Is the app crashing? Can you check if the application's create function is called again about 4s after you attempt to read the I2C sensor?


I checked it by using UART, but I couldn't confirm that trace0("create()") in the application's create function is called again. The counter of timeout function worked correctly after I called temperature_sensor_read_16_bit_register function.

0 Likes

The I suggest toggling a GPIO just before the call to cfa_bsc_OpExtended and then using that as a trigger to capture the I2C bus. What you have in the picture is probably happening because of a bleprofile_*NVRAM() call somewhere close to your call to cfa_bsc_OpExtended().

0 Likes
Anonymous
Not applicable

Hello Y I,

The development team does not believe that you are capturing the correct signals on your scope screen shot.

Thanks

JT

0 Likes
Anonymous
Not applicable

Hi, arvinds and j.t.

I'm sorry for my late reply.

I could confirm that i2c function which I implemented works correctly by using my self made board and the same code. However, I couldn't identify the cause of the problem....I apologize.

I'd like to express my deepest appreciation for your help and support, arvinds and j.t.

0 Likes