AnsweredAssumed Answered

RT1020-EVK: i2c_interrupt demo hangs if printf added (semihost only)

Question asked by rshipman on May 20, 2020
Latest reply on May 26, 2020 by Victor Jimenez

Demo: evkmimxrt1020_lpi2c_interrupt

SDK: 2.7.0

 

Is there some interaction between semihost and the i2c bus?

 

If I run the evkmimxrt1020_lpi2c_interrupt demo out of the box, it works fine.

If I add a PRINTF after the first call to LPI2C_MasterStart in main(), it still works fine and the message is printed to the UART ok.

E.g.:

/* Master start and send address to slave. */

reVal = LPI2C_MasterStart(EXAMPLE_LPI2C_MASTER_BASEADDR, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Write);

if (reVal != kStatus_Success)

{
    return -1;

}

PRINTF("THIS CAUSES DEMO TO HANG IN SEMIHOST MODE"); // Line 266

 

However if I convert the demo to be semihost (so the output goes to the MCUXpresso console window), this PRINTF is printed ok, but causes the demo to hang in the next while loop.

 

The changes I made to convert it to semihost:

SDK_DEBUGCONSOLE=0

Redlib (semihost-nf)

 

The demo justs sits in the following while loop:

/* Wait slave receive finished. */

while (g_slaveRxIndex < LPI2C_DATA_LENGTH)

{

}

 

The variable g_slaveRxIndex is never incremented, stays at 0.

 

Why is this please?

And how can I fix it?

 

Many thanks.

Outcomes