6 years, 2 months ago.

How does mbed handle I2C master functionality interally?


Not certain if this is the best place to seek advice for CMSIS issues, but I'm at my wits' end.

I'm using the second I2C device to communicate with a LM75-like temperature sensor.

I spent a long time not being able to get a response from the LM75 with the CMSIS libs until I used an mbed library from here

Import libraryLM75A

Library for the LM75A Temperature Sensor

which allowed it to work perfectly.

Now that I know the address and I'm confident the actual sensor chip is functioning, I've been trying in earnest to access it using the standard CMSIS I2C library, but it just won't take off.

[Repository '/users/yoonghm/code/CMSIS/docs/c0b2dc6c836f/lpc17xx__i2c_8h.html' not found]


What I really need to know is what the mbed libraries are doing behind the scenes. So I can add any routines or tweak the configuration.

a good summary of my configuration in code

  PINSEL_CFG_Type PinCfg;

  PinCfg.Funcnum     = PINSEL_FUNC_2;
  PinCfg.Pinmode     = PINSEL_PINMODE_PULLUP;
  PinCfg.Portnum     = PINSEL_PORT_0;
  //Set SDA
  PinCfg.Pinnum      = PINSEL_PIN_10; //Refers to LPC1768 pin

  //Set SCL
  PinCfg.Pinnum      = PINSEL_PIN_11; //Refers to LPC1768 pin

//Set line frequency
  I2C_Init(i2c_device, 100000);
  I2C_Cmd(i2c_device, ENABLE);

//Specify slave address and where to put the data
  i2c_cfg.sl_addr7bit = (LM75_SLAVE_ADDR_7) ;
  i2c_cfg.tx_data = tx_buffer;
  i2c_cfg.rx_data = rx_buffer;
  i2c_cfg.rx_length = (BUFFER_SIZE >> 1);

//Queue up an initialise message
  tx_buffer[0] = (LM75_SLAVE_ADDR_7 << 1);
  tx_buffer[1] = 0x01;
  tx_buffer[2] = 0x00;
  i2c_cfg.tx_length = 3;
//Transfer function returns 0, i.e failure
  I2C_MasterTransferData(i2c_device, &i2c_cfg, I2C_TRANSFER_POLLING);

Thank you in advance for any help that can be offered.


Comment on this question
Be the first to answer this question.

To post an answer, please log in.