basic i2c example lpc54628

cancel
Showing results for 
Search instead for 
Did you mean: 

basic i2c example lpc54628

1,144 Views
drkart
Contributor II

Hi,

I am trying to interface to a gps module using i2c : 

https://www.u-blox.com/sites/default/files/NEO-M8-FW3_DataSheet_%28UBX-15031086%29.pdf 

(interface packaged i am using ) neoPLC GPS - High Speed, High Precision GPS for Arduino — neoPLC 

I want the LPC to be the master and the gps to be the slave. (using polling)

I can't seem to get it to work following and modifying any of the i2c examples from the sdk.

I have configured the pins i am using in the pinmux.c file, following the example code:

const uint32_t port0_pin13_config = (
IOCON_PIO_FUNC2 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Input filter disabled */
IOCON_PIO_INPFILT_OFF |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Open drain is enabled */
IOCON_PIO_OPENDRAIN_EN);

IOCON_PinMuxSet(IOCON, 0U, 13U, port0_pin13_config);

const uint32_t port0_pin14_config = (
IOCON_PIO_FUNC2 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Input filter disabled */
IOCON_PIO_INPFILT_OFF |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Open drain is enabled */
IOCON_PIO_OPENDRAIN_EN);

IOCON_PinMuxSet(IOCON, 0U, 14U, port0_pin14_config);

Some questions: 

  1.  Should I be following the examples with "master" or "slave" in the title? I can't get either to work. I do believe I should be following the "master" example though, which is the one i've been messing with the most.
    1. pastedImage_2.png 
  2. Does the naming scheme Flexcomm0...Flexcomm8 also relate to the I2C0_BASE...I2C8_BASE variables int the code?
  3. When I plug the device into 3.3v and gnd , the devices sda and sdl are held at 3.28v....not sure if this is normal.

Any ideas? 

Or if someone can post a very basic stripped down version using i2c to communicate with a slave device?

Thank you!

Labels (2)
0 Kudos
1 Reply

622 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello Kimble! 

1. Should I be following the examples with "master" or "slave" in the title? I can't get either to work. I do believe I should be following the "master" example though, which is the one i've been messing with the most.

You are right, you should be following the master example since your board will act as a master for your project. 

2. Does the naming scheme Flexcomm0...Flexcomm8 also relate to the I2C0_BASE...I2C8_BASE variables int the code?

Yes, if you use I2C0 you should use Flexcomm0, if you are using I2C1 then you need Flexcomm1, etc.

3. When I plug the device into 3.3v and gnd , the devices sda and sdl are held at 3.28v....not sure if this is normal.

Yes, this is normal and you shouldn't have any problem with this.

Thanks for attaching the code of the configurations of the pins you are using for the I2C communication.

The problem you are having is there. You are using Port0_pin13 and Port0_pin14, in both cases you are selecting the function 2 of each pin, as shown below. 

pastedImage_9.png

However, if you reference the user manual of the LPC54628 (UM10912.pdf) in page 189 table 256 you will see the different functions for the pins you are using. See image below. 

pastedImage_10.png

As you can see for  Port0_pin13 and Port0_pin14 the function 2 isn't for the I2C communication, but the function 1 it is. So it seems that this is the problem you are facing since you are selecting the wrong function for both pins. Your pin configuration should be like this. 

const uint32_t port0_pin13_config = (
     `                                        IOCON_PIO_FUNC1 |
                                             /* Selects pull-up function */
                                             IOCON_PIO_MODE_PULLUP |
                                             /* Input function is not inverted */
                                             IOCON_PIO_INV_DI |
                                             /* Enables digital function */
                                             IOCON_PIO_DIGITAL_EN |
                                             /* Input filter disabled */
                                             IOCON_PIO_INPFILT_OFF |
                                             /* Standard mode, output slew rate control is enabled */
                                             IOCON_PIO_SLEW_STANDARD |
                                             /* Open drain is enabled */
                                             IOCON_PIO_OPENDRAIN_EN);

IOCON_PinMuxSet(IOCON, 0U, 13U, port0_pin13_config);

const uint32_t port0_pin14_config = (
     `                                        IOCON_PIO_FUNC1 |
                                             /* Selects pull-up function */
                                             IOCON_PIO_MODE_PULLUP |
                                             /* Input function is not inverted */
                                             IOCON_PIO_INV_DI |
                                             /* Enables digital function */
                                             IOCON_PIO_DIGITAL_EN |
                                             /* Input filter disabled */
                                             IOCON_PIO_INPFILT_OFF |
                                             /* Standard mode, output slew rate control is enabled */
                                             IOCON_PIO_SLEW_STANDARD |
                                             /* Open drain is enabled */
                                             IOCON_PIO_OPENDRAIN_EN);

IOCON_PinMuxSet(IOCON, 0U, 14U, port0_pin14_config);

Hope it helps!

Victor.

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

0 Kudos