This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I have the same problem at TMS570LS1227. Is there any progress on this issue?
Hi,
If the TX interrupt is enabled, the interrupt will be generated even if length = 1. But the HAL generated code has a bug that the TX notification is not called if length=1.
You can modify the I2C ISR as:
Original code;
==================================
case 5U:
/* USER CODE BEGIN (42) */
/* USER CODE END */
/* transmit */
if (g_i2cTransfer_t.length > 0U)
{
i2cREG1->DXR = *g_i2cTransfer_t.data;
/*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
g_i2cTransfer_t.data++;
g_i2cTransfer_t.length--;
if(g_i2cTransfer_t.length == 0U)
{ /* Disable TX interrupt after desired data count transfered*/
i2cREG1->IMR &= (uint32)(~(uint32)I2C_TX_INT);
i2cNotification(i2cREG1, (uint32)I2C_TX_INT);
}
}
break;
=================================
Modified code;
==================================
case 5U:
/* USER CODE BEGIN (42) */
/* USER CODE END */
/* transmit */
if (g_i2cTransfer_t.length > 0U)
{
i2cREG1->DXR = *g_i2cTransfer_t.data;
/*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
g_i2cTransfer_t.data++;
g_i2cTransfer_t.length--;
}
if(g_i2cTransfer_t.length == 0U)
{ /* Disable TX interrupt after desired data count transfered*/
i2cREG1->IMR &= (uint32)(~(uint32)I2C_TX_INT);
i2cNotification(i2cREG1, (uint32)I2C_TX_INT);
}
break;
=================================
Hi,
Thank you very much for your quick reply. Actually, I tried your workaround but not working for me because the i2cInterrupt function is not calling by the microcontroller when length = 1. Everything is well when I change the length = 2. So I think the problem may be hardware related. Have you tried your solution? Is this workaround working in your setup?
The INT should be generated even if length=1
I2C_send(){
....
/* Length -1 since one data is written already */
g_i2cTransfer_t.length = (length - 1U);
/* Enable Transmit Interrupt */
i2c->IMR |= (uint32)I2C_TX_INT;
}
I will do a quick test