cannot disable I2C interrupt in MKE02Z using PE

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

cannot disable I2C interrupt in MKE02Z using PE

1,068 Views
gschelotto
Contributor V

Hi,

I've disabled I2C_LDD interrupt as shown

Untitled.png

Then generate the PE code, compile and debug. Finally I set a breakpoint in the I2C tx event routine and the execution halts as shown

Untitled.png

This is a non expected result. How can I disable these rx/tx I2C interrupts?

regards,

gaston

0 Kudos
Reply
4 Replies

742 Views
gschelotto
Contributor V

Hello Marek,

Here's the PE typical usage example:

volatile bool DataReceivedFlg = FALSE;

volatile bool DataTransmittedFlg = FALSE;

uint8_t OutData[4] = {0x00U, 0x01U, 0x02U, 0x03U}; /* Initialization of output data buffer */

uint8_t InpData[16];

LDD_TError Error;

LDD_TDeviceData *MyI2CPtr;

void main(void) {

     MyI2CPtr = I2C2_Init(NULL); /* Initialization of I2C2 component */ /* Configure I2C BUS device(e.g. RTC) - Write Operation */

     Error = I2C2_MasterSendBlock(MyI2CPtr, OutData, 4U, LDD_I2C_SEND_STOP);

      while (!DataTransmittedFlg) { /* Wait until OutData are transmitted */

          I2C2_Main(MyI2CPtr);

     }

     DataTransmittedFlg = FALSE; /* Read configuration of I2C BUS device(e.g. RTC) - Read Operation */

     OutData[0] = 0x00U; /* Initialization of OutData buffer */

     Error = I2C2_MasterSendBlock(MyI2CPtr, OutData, 1U, LDD_I2C_NO_SEND_STOP);

     while (!DataTransmittedFlg) { /* Wait until OutData are transmitted */

          I2C2_Main(MyI2CPtr);

     }

     DataTransmittedFlg = FALSE;

     Error = I2C2_MasterReceiveBlock(MyI2CPtr, InpData, 16U, LDD_I2C_SEND_STOP);

     while (!DataReceivedFlg) { /* Wait until InpData are received */

          I2C2_Main(MyI2CPtr);

     }

     DataReceivedFlg = FALSE;

     for(;;) {}

}

The problem is DataTransmittedFlg is not changed to true by Events (I2C interrupts disabled) nor I2C_Main function. So the execution is stuck at the first while()

regards,

gaston

0 Kudos
Reply

742 Views
marek_neuzil
NXP Employee
NXP Employee

Hello Gaston,

When the interrupt service is disabled the Main() function is called in the application. This function calls events that are enabled. See the following part of the source code of the Main() function:

. . .

if ((DeviceDataPrv->EventMask & LDD_I2C_ON_MASTER_BLOCK_SENT) != 0x00U) {

  CI2C1_OnMasterBlockSent(DeviceDataPrv->UserData); /* Invoke OnMasterBlockSent event */

}

. . .

If you want to disable calling of the event you must use the SetEventMask() function of the I2C_LDD component.

For example:

SetEventMask(MyI2CPtr, 0); /* disable all events */

Best Regards,

Marek Neuzil

0 Kudos
Reply

742 Views
gschelotto
Contributor V

Hello Marek,

Thank you. Now the Event calling is disabled but I cannot transmit I2C data anymore. Even using the Main() function as suggested in I2C_LDD Help on Component for Sending/Receiving data in the MASTER mode, without interrupt service (polling)

Here's my I2C 2-byte sending routine

// check I2C bus

timeout = TCA9555_I2C_TIMEOUT;

do{

     timeout--;

     Error = CI2C1_CheckBus(TCA9555Struct.handle, &BusState);

}

while(BusState != LDD_I2C_IDLE && timeout && Error == ERR_OK);

if(Error != ERR_OK || timeout == 0)

     return ERR_FAILED;

timeout = TCA9555_I2C_TIMEOUT;

buf[1] = reg.data[0];

buf[0] = TCA9555_CONFIG_REG0;

// Send I2C address plus 1 bytes to the I2C bus with a stop condition

Error = CI2C1_MasterSendBlock(TCA9555Struct.handle, &buf, 2U, LDD_I2C_SEND_STOP);

do{

     timeout--;

     CI2C1_Main(TCA9555Struct.handle);

} while(!TCA9555Struct.dataTransmittedFlg && timeout);    // Wait until data is sent

if(Error != ERR_OK || timeout == 0)

     return ERR_FAILED;

else

     TCA9555Struct.dataTransmittedFlg = FALSE;

Do you perceive something wrong?

regards,

gaston

0 Kudos
Reply

742 Views
marek_neuzil
NXP Employee
NXP Employee

Hello Gaston,

I have checked your code but I only see possible issue in the timeout. There is not any timer used and the loop can be executed very fast, i.e. there is not guaranteed any real timeout by the following loop:

do{ 

     timeout--; 

     CI2C1_Main(TCA9555Struct.handle); 

} while(!TCA9555Struct.dataTransmittedFlg && timeout);    // Wait until data is sent 

Best Regards,

Marek Neuzil

0 Kudos
Reply