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

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

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

628 Views
rshipman
Contributor V

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.

Labels (1)
0 Kudos
1 Reply

585 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello, 

When using the semihosting is important to keep in mind the following: 

Semihosting operations cause the CPU to drop into “debug state”, which means that for the duration of the data transfer between the target and the host PC no code (including interrupts) will get executed on the target. Thus if your application uses interrupts, then it is normally advisable to avoid the use of semihosting whilst interrupts are active – and certainly within interrupt handlers themselves.

After calling the function LPI2C_MasterStart, the Master will start sending data to the Slave. The slave receives the data through the Interrupt handler. Having the semihosting at this point in your application is causing that the Slave misses the interrupts of the receiving data.

Have a great day,

Victor

-------------------------------------------------------------------------------

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