1
\$\begingroup\$

I am using the M24LR16-E EEPROM which is an I2C device:

http://www.st.com/content/ccc/resource/technical/document/datasheet/56/58/3c/91/80/a4/49/89/DM00031737.pdf/files/DM00031737.pdf/jcr:content/translations/en.DM00031737.pdf

I am using the Nordic nRF52 Development Board for the EEPROM to be intefaced to.

In Nordic's SDKv12, there is a sample application which uses TWI to scan for connected I2C devices with the microcontroller. Kindly see code snippet below for the scanning procedure.

When I run this, the M24LR16-E cannot be detected. However, when I connect a Bosch's Barometric Pressure Sensor (BMP180) to the I2C bus, both of them are detected and the correct device select codes are printed.

Why is this happening? The read and write functions that I wrote for the M24LR16-E are working, though. Does this have anything to do with timing issues?

Thank you in advance.

Scanning for I2C device procedure:

for (address = 1; address <= 127; address++)
{
   err_code = nrf_drv_twi_rx(&m_twi, //twi config structure
                             address, //device select code 
                             &sample_data,sizeof(sample_data));
   if (err_code == NRF_SUCCESS)
   {
       detected_device = true;
       NRF_LOG_INFO("TWI device detected at address 0x%x.\r\n", address);
   }
   NRF_LOG_FLUSH();
}

if(!detected_device)
{
    NRF_LOG_INFO("No device was found.\r\n");
    NRF_LOG_FLUSH();
}

Also see image for the outputs (both EEPROM and pressure sensor connected to the I2C bus):

enter image description here

\$\endgroup\$
5
  • 1
    \$\begingroup\$ It would help if you clarify what you mean by "when I connect a Bosch's Barometric Pressure Sensor (BMP180) to the I2C bus" - how many wires to the pressure sensor do you actually connect/disconnect during that specific change? Is it 1 wire (e.g. power only), leaving all the others connected? Or is it all 4 (power, SDA, SCL, gnd)? Or is it something else? If I was in your position, I would also use a 'scope to view the I2C bus signals & compare "EEPROM reported" vs. "EEPROM not reported" I2C scan, to see if the I2C waveform shapes or timing were significantly different between them. \$\endgroup\$ – SamGibson Dec 28 '16 at 11:55
  • \$\begingroup\$ Hello @SamGibson, by saying connect I mean removing the Bosch's Barometric Pressure Sensor (BMP180) from the breadboard. Unfortunately, I don't have an oscilloscope or such devices right now. \$\endgroup\$ – J. A. De la Peña Dec 29 '16 at 0:38
  • \$\begingroup\$ J. A. De la Peña - Thanks. My guess, like in DoxyLover's answer, is that your BMP180 is on a typical breakout board which includes I2C pull-up resistors (if that is wrong then please clarify and ideally provide a photo of your hardware inc your BMP180). If my guess is correct, then removing the BMP180 breakout (with those pull-ups) would change the I2C signal rise & fall times. However this doesn't explain why your I2C r/w code works for both tests, but the I2C scan code only works with the BMP180 connected. Unfortunately I don't see a way to make clear progress, without using a 'scope :-( \$\endgroup\$ – SamGibson Dec 29 '16 at 1:36
  • \$\begingroup\$ Hello, thank you so much for you answer, SamGibson. I just saw that DoxyLover's guess was correct. I tried connecting the BMP180 directly to the SCL and SDA pins of the MCU without pullups and it was detected. However, in the BMP180 schematic, there is a sample application schematic which shows pullups connected. I also tried connecting the EEPROM with 4.7K Ohms pullups but still was not detected. I will continue research on my part. Many thanks \$\endgroup\$ – J. A. De la Peña Dec 29 '16 at 3:49
  • \$\begingroup\$ What are the contents of the sample_data data structure? You might be trying to read from an unsupported register. \$\endgroup\$ – Adam Lawrence Jan 26 '18 at 16:52
1
\$\begingroup\$

I2C requires pull-up resistors on the SCL and SDA lines. In reading the description of the BMP180 breakout board, though I didn't find explicit mention, it aspears that it has the pull-ups in that board since it shows wiring directly to an Aduino.

Try connecting two 4.7Kohm resistors, one from SCL to Vcc and one from SDA to Vcc.

\$\endgroup\$
2
  • \$\begingroup\$ Hello, I have connected 4.7Kohm resistors on both the SDA and SCL lines. This is the reason why I'm very puzzled with this. My hardware setup is working well since I have used the same setup before. \$\endgroup\$ – J. A. De la Peña Dec 28 '16 at 7:54
  • \$\begingroup\$ I have connnected the 2 pullup resistors from the very beginning \$\endgroup\$ – J. A. De la Peña Dec 28 '16 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.