XMC I2C_MASTER APP getting stuck with no slave connected

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User12943
Level 1
Level 1
Hi,
I have an XMC-1404 running the I2C_MASTER app connected to a LCD screen with an I2C expander.

If the LCD is not connected or there is an error in the transmission the APP gets stuck at line 1519 in i2c_master.c:

    while (I2C_MASTER_GetFlagStatus(handle, (uint32_t)XMC_I2C_CH_STATUS_FLAG_ACK_RECEIVED) == 0U)
{
/* wait for ACK */
}


I am using this command to send data to the LCD:
I2C_MASTER_Transmit(&I2C_MASTER_0,true,I2C_SLAVE_ADDR,lcd_data,6,true);


Is there any way to prevent this?

Thanks,
Nico
0 Likes
6 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

This is actually a shortcoming of the current version of the APP in polling mode
The APP should check also for the non acknowledge case.

    if (send_start == true)
{
if (handle->runtime->bus_acquired == false)
{
I2C_MASTER_lSendStart_Or_RepeatedStart(handle, slave_address, XMC_I2C_CH_CMD_WRITE);
while (I2C_MASTER_GetFlagStatus(handle, XMC_I2C_CH_STATUS_FLAG_ACK_RECEIVED | XMC_I2C_CH_STATUS_FLAG_NACK_RECEIVED) == 0U);
if (I2C_MASTER_GetFlagStatus(handle, XMC_I2C_CH_STATUS_FLAG_NACK_RECEIVED))
{
I2C_MASTER_ClearFlag(handle, (uint32_t)XMC_I2C_CH_STATUS_FLAG_NACK_RECEIVED);
I2C_MASTER_AbortTransmit(handle);
return I2C_MASTER_STATUS_FAILURE;
}
else
{
I2C_MASTER_ClearFlag(handle, (uint32_t)XMC_I2C_CH_STATUS_FLAG_ACK_RECEIVED);
}
}
}


In the interrupt mode you could enable the error handling of NACK. In the callback you should call the I2C_MASTER_AbortTransmit()

Regards,
Jesus
0 Likes
User12943
Level 1
Level 1
Thanks for that Jesus, I'll give it a go this week and let you know how I get on.

Nico
0 Likes
User12943
Level 1
Level 1
Hi Jesus,
I have now managed to get it to work successfully, however it wasn't as easy as you described!

I enabled the I2C interrupt mode and the code now got stuck with TDV bit enabled - XMC_USIC_CH_TBUF_STATUS_BUSY but no transmission occurring.

I my code detects that this occurs I have to write 10b to the MTDV bits and then restart the transmission.

Why is this not carried out with the Dave app with the I2C_MASTER_AbortTrasmit function as this procedure is described in the datasheet "17.5.3.5 Not Acknowledge and Error Conditions"?

Thanks,
Nico
0 Likes
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi Nico,

Thanks for the feedback. We will fix it in the next release.

Regards,
Jesus
0 Likes
User10239
Level 1
Level 1
Welcome! 10 replies posted 5 replies posted
Hi there!

I have managed the issue with I2C-Bus by reinitializing the bus if there is a problem with bus devices
Take account on example code for XMC4500 with DAVE 4 CE at
https://github.com/haselb/ISOT


regards
0 Likes

Thanks for that, I solved a similar issue using your code as below, the init routine wasn't enough on it's own, needed the abort transmit / receive first.

I2C_MASTER_AbortTransmit(&I2C_MASTER_0);
I2C_MASTER_AbortReceive(&I2C_MASTER_0);
I2C_MASTER_Init(&I2C_MASTER_0);

Brendan

 

0 Likes