I2C Tools and Work Flow

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

I2C Tools and Work Flow

632 Views
daniel_harthan
Contributor I

I am working with a LPCXpresso 1115 /303. I have never used I2C before, so I really do not know the basic work flow to set up communications. Yes I have read All Board I2C tools, but I do not know how to find or enable it in LPCXpresso IDE v8.2.2_650. No idea what tools do what or even what is relevant to what I am trying to do. 

I want to control servos using the aidafruit 16 channel servo controller, it has a default address of 0x40. All of the examples for the controller are using arduino, so not much help. I do not know the number of write bits, or how to address a specific servo channel on the board. I have gone through the manual and have been working with the I2C_main example to try and get to work. At this point I am just shooting in the dark, and I cant even figure out where to input the address of the slave device. 

I am not sure where to start with this project, so any help (especially on the best use of the IDE) would be greatly appreciated. 

The last thing that I cannot figure out is what value I am supposed to send to the servo controller. Do I send a desired degree? PWM duty cycle? Pulse width value? No idea what data I need to send to get the driver to work. 

Labels (1)
0 Kudos
2 Replies

445 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello Daniel Harthan

Lets go step by step to solve your case. First it's important that you understand how I2C protocol works. Based on what you wrote I understood that you read the information of I2C that is available in the user manual of the LPC that you are using, this is a good starting point. However, it will be better if you read first the next document: I2C-bus specification and user manual . This document explains all you need to know about I2C protocol. 

Once you understood how I2C works the next thing to do is look at an I2C example for the LPC that you are using. The LPC1115 has a package of examples named LPCOpen, here you will find an example of the I2C peripheral among any others. If you are using LPCXpresso you can find these examples in the next path: 

  • C:\nxp\LPCXpresso_8.2.2_650\lpcxpresso\Examples\LPCOpen\lpcopen_v2_00a_lpcxpresso_nxp_lpcxpresso_11c24.zip

Please noticed that LPC11c24 and LPC1115 are from the same family, so you can use these examples without any problems. Inside this folder you will find the I2C example. You need to import this to your LPCXpresso IDE and debug this step by step so you can understand how this works. Definitely, this as good starting point to your project and you can use this as a guide to talk with the servo controller. 

I made a little research and I think that the servo controller that you are using is the next one: https://www.adafruit.com/product/815 is this correct?  If so, I noticed that the controller is an NXP part, so you can reference the following page to learn more about this: 

In the datasheet of this part you will find everything you need to know on how to talk to this controller in PWM mode that is the one you will be using. If you are using a different controller please let me know which one to see if it's also an NXP part.

Once you follow all the steps mentioned before you shouldn't have any problems to work with the servo controller. 

Hope it helps!

Victor.

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

0 Kudos

445 Views
daniel_harthan
Contributor I

Victor,

Thank you for the reply. I think that I have found my problem. In the provided i2c.c file the i2cengine handles the device address and read/write bit as a single write value. I was passing 0x40 (1000000) as the address, and assumed that the engine would add the (0) on the end to indicate a write condition. I was actually passing (0x20)(0) where the last bit was the read/write for the 8bit sequence and not counted toward the address. This was corrected by changing the address to 0x80, then | with 0x01 later if I wanted to read from a register. Hopefully this helps others in the future. 

The only other issue that I found is the PCA9685 will default to sleep and shuts off the internal clock. I needed to initialize the clock and write a 0x21 to the MODE1 regiser to enable the clock and enable all channels for driver communications on every startup. 

Thanks again for the help. 

0 Kudos