I2C sample from SDK does not work on LPCXpresso5411x development board

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

I2C sample from SDK does not work on LPCXpresso5411x development board

Jump to solution
1,597 Views
misterbee
Contributor II

I have with me LPCXpresso5411x development board. I use MCUXpresso IDE to import a project sample freertos_i2c. It can build and run the debugger. However it seems there is no I2C communication establish, the callback i2c_slave_callback() is not triggered at all.

The following init is success:

status = I2C_RTOS_Init(&master_rtos_handle, EXAMPLE_I2C_MASTER, &masterConfig, sourceClock);

 

However the following attempt for master to transfer data fail with status 2611:

status = I2C_RTOS_Transfer(&master_rtos_handle, &masterXfer);
if (status != kStatus_Success)
{
PRINTF("I2C master: error during write transaction, %d", status);
}

 

I am expecting it works just out of the box, or is there anything I miss or should preconfigure before?

Tags (3)
0 Kudos
1 Solution
1,576 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi misterbee,

 

There isn't any pre-configuration needed to run the i2c example. Could you please re-confirm both i2c connections?

 

I2C1 connected to I2C2

SCL P0_25(J1 pin1) --> P0_18(J1 pin11)

SDA P0_26(J1 pin3) --> P0_20(J1 pin13)

 

Can you also please confirm if you are connecting any extra boards or any other component? Did you modify the SDK example?

 

Best regards, Julian

View solution in original post

0 Kudos
8 Replies
1,528 Views
misterbee
Contributor II

Just want to attach the snapshot of the error log from com port

 

misterbee_0-1653463790919.png

 

0 Kudos
1,529 Views
misterbee
Contributor II

Thank you @Julián_AragónM , I can see the instruction now to setup connection I2C1 <-> I2C2.

Should I expect this setup already done when I download the sdk sample? Or I have to do this in addition?

0 Kudos
1,526 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @misterbee,

Could you please attach a picture of your physical setup? 

Best regards, Julian

0 Kudos
1,519 Views
misterbee
Contributor II

Hi @Julián_AragónM ,

It is now resolved, silly me, just realized need to do wiring to physically connect between the two I2C :D.

Thank you for showing me the instruction doc, otherwise I would not be aware of this :).

 

0 Kudos
1,546 Views
misterbee
Contributor II

Hi @Julián_AragónM ,

I saw this in the code, will this help to answer your question about the I2C connection?

 

/* clang-format off */
/*
 * TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
BOARD_InitPins:
- options: {callFromInitBoot: 'true', coreID: cm4, enableClock: 'true'}
- pin_list:
  - {pin_num: '31', peripheral: FLEXCOMM0, signal: RXD_SDA_MOSI, pin_signal: PIO0_0/FC0_RXD_SDA_MOSI/FC3_CTS_SDA_SSEL0/CTIMER0_CAP0/SCT0_OUT3, mode: inactive, invert: disabled,
    glitch_filter: disabled, slew_rate: standard, open_drain: disabled}
  - {pin_num: '32', peripheral: FLEXCOMM0, signal: TXD_SCL_MISO, pin_signal: PIO0_1/FC0_TXD_SCL_MISO/FC3_RTS_SCL_SSEL1/CTIMER0_CAP1/SCT0_OUT1, mode: inactive, invert: disabled,
    glitch_filter: disabled, slew_rate: standard, open_drain: disabled}
  - {pin_num: '3', peripheral: FLEXCOMM4, signal: RTS_SCL_SSEL1, pin_signal: PIO0_25/FC4_RTS_SCL_SSEL1/FC6_CTS_SDA_SSEL0/CTIMER0_CAP2/CTIMER1_CAP1, invert: disabled,
    glitch_filter: disabled, i2c_slew: i2c, i2c_drive: low, i2c_filter: enabled}
  - {pin_num: '4', peripheral: FLEXCOMM4, signal: CTS_SDA_SSEL0, pin_signal: PIO0_26/FC4_CTS_SDA_SSEL0/CTIMER0_CAP3, invert: disabled, glitch_filter: disabled, i2c_slew: i2c,
    i2c_drive: low, i2c_filter: enabled}
  - {pin_num: '58', peripheral: FLEXCOMM5, signal: TXD_SCL_MISO, pin_signal: PIO0_18/FC5_TXD_SCL_MISO/SCT0_OUT0/CTIMER0_MAT0, mode: inactive, invert: disabled, glitch_filter: disabled,
    slew_rate: standard, open_drain: disabled}
  - {pin_num: '60', peripheral: FLEXCOMM5, signal: RXD_SDA_MOSI, pin_signal: PIO0_20/FC5_RXD_SDA_MOSI/FC0_SCK/CTIMER3_CAP0, mode: inactive, invert: disabled, glitch_filter: disabled,
    slew_rate: standard, open_drain: disabled}
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
 */
/* clang-format on */

/* FUNCTION ************************************************************************************************************
 *
 * Function Name : BOARD_InitPins
 * Description   : Configures pin routing and optionally pin electrical features.
 *
 * END ****************************************************************************************************************/
/* Function assigned for the Cortex-M4F */
void BOARD_InitPins(void)
{
    /* Enables the clock for the IOCON block. 0 = Disable; 1 = Enable.: 0x01u */
    CLOCK_EnableClock(kCLOCK_Iocon);

    const uint32_t port0_pin0_config = (/* Pin is configured as FC0_RXD_SDA_MOSI */
                                        IOCON_PIO_FUNC1 |
                                        /* No addition pin function */
                                        IOCON_PIO_MODE_INACT |
                                        /* 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 disabled */
                                        IOCON_PIO_OPENDRAIN_DI);
    /* PORT0 PIN0 (coords: 31) is configured as FC0_RXD_SDA_MOSI */
    IOCON_PinMuxSet(IOCON, 0U, 0U, port0_pin0_config);

    const uint32_t port0_pin1_config = (/* Pin is configured as FC0_TXD_SCL_MISO */
                                        IOCON_PIO_FUNC1 |
                                        /* No addition pin function */
                                        IOCON_PIO_MODE_INACT |
                                        /* 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 disabled */
                                        IOCON_PIO_OPENDRAIN_DI);
    /* PORT0 PIN1 (coords: 32) is configured as FC0_TXD_SCL_MISO */
    IOCON_PinMuxSet(IOCON, 0U, 1U, port0_pin1_config);

    const uint32_t port0_pin18_config = (/* Pin is configured as FC5_TXD_SCL_MISO */
                                         IOCON_PIO_FUNC1 |
                                         /* No addition pin function */
                                         IOCON_PIO_MODE_INACT |
                                         /* 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 disabled */
                                         IOCON_PIO_OPENDRAIN_DI);
    /* PORT0 PIN18 (coords: 58) is configured as FC5_TXD_SCL_MISO */
    IOCON_PinMuxSet(IOCON, 0U, 18U, port0_pin18_config);

    const uint32_t port0_pin20_config = (/* Pin is configured as FC5_RXD_SDA_MOSI */
                                         IOCON_PIO_FUNC1 |
                                         /* No addition pin function */
                                         IOCON_PIO_MODE_INACT |
                                         /* 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 disabled */
                                         IOCON_PIO_OPENDRAIN_DI);
    /* PORT0 PIN20 (coords: 60) is configured as FC5_RXD_SDA_MOSI */
    IOCON_PinMuxSet(IOCON, 0U, 20U, port0_pin20_config);

    const uint32_t port0_pin25_config = (/* Pin is configured as FC4_RTS_SCL_SSEL1 */
                                         IOCON_PIO_FUNC1 |
                                         /* I2C mode */
                                         IOCON_PIO_I2CSLEW_I2C |
                                         /* Input function is not inverted */
                                         IOCON_PIO_INV_DI |
                                         /* Enables digital function */
                                         IOCON_PIO_DIGITAL_EN |
                                         /* Input filter disabled */
                                         IOCON_PIO_INPFILT_OFF |
                                         /* Low drive: 4 mA */
                                         IOCON_PIO_I2CDRIVE_LOW |
                                         /* I2C 50 ns glitch filter enabled */
                                         IOCON_PIO_I2CFILTER_EN);
    /* PORT0 PIN25 (coords: 3) is configured as FC4_RTS_SCL_SSEL1 */
    IOCON_PinMuxSet(IOCON, 0U, 25U, port0_pin25_config);

    const uint32_t port0_pin26_config = (/* Pin is configured as FC4_CTS_SDA_SSEL0 */
                                         IOCON_PIO_FUNC1 |
                                         /* I2C mode */
                                         IOCON_PIO_I2CSLEW_I2C |
                                         /* Input function is not inverted */
                                         IOCON_PIO_INV_DI |
                                         /* Enables digital function */
                                         IOCON_PIO_DIGITAL_EN |
                                         /* Input filter disabled */
                                         IOCON_PIO_INPFILT_OFF |
                                         /* Low drive: 4 mA */
                                         IOCON_PIO_I2CDRIVE_LOW |
                                         /* I2C 50 ns glitch filter enabled */
                                         IOCON_PIO_I2CFILTER_EN);
    /* PORT0 PIN26 (coords: 4) is configured as FC4_CTS_SDA_SSEL0 */
    IOCON_PinMuxSet(IOCON, 0U, 26U, port0_pin26_config);
}
0 Kudos
1,577 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi misterbee,

 

There isn't any pre-configuration needed to run the i2c example. Could you please re-confirm both i2c connections?

 

I2C1 connected to I2C2

SCL P0_25(J1 pin1) --> P0_18(J1 pin11)

SDA P0_26(J1 pin3) --> P0_20(J1 pin13)

 

Can you also please confirm if you are connecting any extra boards or any other component? Did you modify the SDK example?

 

Best regards, Julian

0 Kudos
1,550 Views
misterbee
Contributor II

Hi @Julián_AragónM ,

Thank you for the response. I don't connect to any board nor I modify the SDK. I just take a fresh board and load the sample from the IDE.

 

Where can check this? From the code? which file/function?

"I2C1 connected to I2C2

SCL P0_25(J1 pin1) --> P0_18(J1 pin11)

SDA P0_26(J1 pin3) --> P0_20(J1 pin13)"

0 Kudos
1,540 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @misterbee,

 

This is in the "readme" file under docs folder in your project folder. It can be found in "...\Documents\MCUXpressoIDE_11.5.1_7266\workspace\lpcxpresso54114_freertos_i2c\doc"

 

There you can find the instructions to run the project.

 

Best regards, Julian

0 Kudos