I2C library config for LPC1769

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I2C library config for LPC1769

3,360 Views
m4kes_no_sense
Contributor I

Hi I'm making a project with an LPC1769. I'm trying to make a pulsioximeter using a MAX30100. This device is an optical sensor with an adc that transmit the data that it sense using I2C (and much more but this is the important part). So I'm trying to config the I2C of this divice with my LPC1769, I downloaded a lpcopen library from another question post that has an example of how to use the I2C in a LPC1768. So I search for the datasheet of the LPC1769 and its seems that the pins that the I2C uses are the same, so i think I dont have to change anything from the I2C1Init function from i2c.c (I will just use the I2C1 pin 19 and 20).
Well the question is that I don't know which things I have to pay attention and which not in the library, for example I know that I have to change the adress of the divice (which I know is 0xAE ) and some values for the externs (I2C Master and Slave Buffer , and read and write length) which will depend in the way that my device sends the data, but I dont know if I'm not considering something important.

The lpcopen library is attached in this post.

Thank you for your help and time

kerryzhou

Labels (2)
0 Kudos
7 Replies

2,013 Views
marcos299long
Contributor I

Hello, I am wanting to use the max30100 with the lpc845 but I have enough problems to understand the communication with the i2c, could you share any code? Thank you

0 Kudos

2,618 Views
jsabUTN
Contributor I

Good morning and excuse me for my late response!

I'm doing almost the same thing (using max30100 with a LPC1769) as a school project. I wanted to ask how it ended and if i can borrow and example of it.

I wish you the best!

0 Kudos

2,831 Views
m4kes_no_sense
Contributor I

I forgot to say that I have made the same project in Arduino, so I'm trying to use the same program making some changings. The main functions that use the I2C are the next ones:

void MAX30100::writeRegister(byte address, byte val)
{
//Wire.beginTransmission(MAX30100_DEVICE); // start transmission to device
// Wire.write(address); // send register address
// Wire.write(val); // send value to write
// Wire.endTransmission(); // end transmission
I2CWriteLength[PORT_USED] = 3;
I2CReadLength[PORT_USED] = 0;
I2CMasterBuffer[PORT_USED][0] = MAX30100_DEVICE;
I2CMasterBuffer[PORT_USED][1] = address;
I2CMasterBuffer[PORT_USED][2] = val;
I2CEngine( PORT_USED );

}


uint8_t MAX30100::readRegister(uint8_t address) 
// Wire.beginTransmission(MAX30100_DEVICE);
// Wire.write(address);
// Wire.endTransmission(false);
// Wire.requestFrom(MAX30100_DEVICE, 1);

// return Wire.read();
int i;
for ( i = 0; i < BUFSIZE; i++ )
{
I2CSlaveBuffer[PORT_USED][i] = 0x00;
}
I2CWriteLength[PORT_USED] = 3;
I2CReadLength[PORT_USED] = 1;
I2CMasterBuffer[PORT_USED][0] = MAX30100_DEVICE;
I2CMasterBuffer[PORT_USED][1] = address;
I2CMasterBuffer[PORT_USED][2] = MAX30100_DEVICE | RD_BIT;
I2CEngine( PORT_USED );

return I2CSlaveBuffer[PORT_USED][0];

}

As you can see I've used some of the i2c.h lpcopen functions trying to adapt the arduino wire.h functions.
The idea of the MAX30100::writeRegister function is to write a specific register (that i choose with "address" value) in the MAX30100 with a byte value(withe "value"), and the MAX30100::readRegister function is to read an specific  register (that i choose with "address" value) and store that value in I2CSlaveBuffer[PORT_USED][0]. I dont know if I'm using the i2c.h functions well and I can't probe it yet, cause I have some other issues in the program, so for now I just want to know if what I'm doing makes any sense or if I didn't understand how the i2c works.

Sorry for my English, I hope you would be able to understand what I'm saying and again thank for your support

0 Kudos

2,831 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Javier Nakama,

    I already receive your message about this question.

    Now, after you modify the code bundle I2C example to meet your own external sensor demand, do you test the I2C bus wave? You can check the I2C bus wave, when you send the address, whether your slave can give the ACK or not? Whether the address is correct in the I2C bus?

   Take an example:

pastedImage_1.png

This the I2C bus logic analyzer wave, you can find when send the slave addr=0x2d, the slave give the ACK, it means the LPC can communicate with the I2C slave side.

So, I highly recommend you test the I2C bus, then associated with your lpc code to test the function, this is will be more efficient.

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,897 Views
Nadine_
Contributor I

Hello Sir, 

 

i know this is already an old discussion, but i have one question. I‘m trying to measure heart rate and Spo2 using MAX30102 and already tested it with logic analyzer. I can write and read data so that i‘m sure the configuration is alright. The problem is, as i tested using logic analyzer, i only get signal from IR LED and not from RED. That is in SpO2 mode. What could cause this problem? 

I‘d really appreciate it if you could help me, thank you. 

 

 

Best regards, 

0 Kudos

2,831 Views
m4kes_no_sense
Contributor I

Well I don't know how to see I2C wave as you did in the image. But what I have done is to test the I2C code with the EEPROM in the LPC, there I could undestand more about the code and the protocol I2C itself. I made some changes and manage to make the EEPROM work because the example made some mistakes, and in order to do that i run the program and follow the code step by step and follow every I2C status value. So I think I-m gonna do the same for the MAX30100, I will try to write a register and then read tthe same register and store it in some special buffer in order to know if I'm doing it right. I will notice you the results
If you want I can attached the modified code, I've probed it and it works perfectly.
One more question , I have some libraries of my own and I want to use the i2c.h library, what is the right way of including the library , I mean to use them all in the same project, cause I'm having some problems with the IDE and the includes that doesn't recognize other libraries, or when I try to build the project some errors appear in my project that doesn't appear when I build the some .h in the lpcopen project. Here is an example of that:

Errors.png

As you can see, there are 4 errors in that line (which doesn't have any problem when I build the I2C project of the lpcopen library), and I have to manually copy and paste all the libraries in the "src" foulder because the #includes didn't find the libraries (for example the LPC17xx.h).

Thank you a lot for your support Kerry

0 Kudos

2,831 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Javier Nakama,

   The I2c wave which I give you is using the Logic analyzer to test it, you also can use the oscilloscope to check the I2C bus wave, but you need to identify the I2C data by yourself.

   About your i2c.h lib problem, it seems you didn't add the CMSISV2_LP17XX in your code bundle package, I have tried it on my side, it builds without any errors.

pastedImage_1.png

You can try to import the CMSIS lib, then try it again.


Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos