cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

New Contributor II

Hi all,

I am currently working on a PSoC-to-PSoC I2C communication. On the slave device, I'm using a EZI2C component. I can correctly perform read and write operation from the Bridge Control Panel and everything is working as expected.

The problem that I'm trying to solve is the following: based on the values that are written from the master device to the slave device, I need to perform some actions. My idea was to use the EZI2C_ISR_ExitCallback callback function and the EZI2C_GetActivity() function:

void EZI2C_ISR_ExitCallback(void)

{

     if ( 0u != (EZI2C_GetActivity() & EZI2C_STATUS_WRITE1) & 0u == (EZI2C_GetActivity() & EZI2C_STATUS_ERR) )

     {

          // Write operation completed, check values and perform actions..

     }

}

What I am currently experiencing is that the function EZI2C_GetActivity() always return either EZI2C_STATUS_BUSY or a 0 value, therefore I cannot check if a write operation was completed inside the callback.

Does somebody has any idea on the cause of this "issue"?

Thanks,

Davide

0 Likes
Reply
1 Solution
Moderator
Moderator

Hi DaMa_3386091

The reason for this behavior is that EZI2C_GetActivity clears the status after read. The callback function is also triggered before the write is complete (write operation is received and EZI2C component is busy) and when EZI2C_GetActivity() is called here, it clears status bit and write complete condition is lost.

The solution to this is to use the status flag variable directly. You can obtain the variable by declaring the extern variable:

extern volatile uint8 EZI2C_curStatus;

Then, the EZI2C_curStatus can be checked to confirm that the write operation is complete.

The code will be

extern volatile uint8 EZI2C_curStatus;

void EZI2C_ISR_ExitCallback()

{

    volatile uint8 temp = EZI2C_curStatus;//EZI2C_GetActivity();

    if(temp == EZI2C_STATUS_WRITE1)

    {

        //Application code here

    }

   

}

Best regards,

Hari

View solution in original post

0 Likes
Reply
1 Reply
Moderator
Moderator

Hi DaMa_3386091

The reason for this behavior is that EZI2C_GetActivity clears the status after read. The callback function is also triggered before the write is complete (write operation is received and EZI2C component is busy) and when EZI2C_GetActivity() is called here, it clears status bit and write complete condition is lost.

The solution to this is to use the status flag variable directly. You can obtain the variable by declaring the extern variable:

extern volatile uint8 EZI2C_curStatus;

Then, the EZI2C_curStatus can be checked to confirm that the write operation is complete.

The code will be

extern volatile uint8 EZI2C_curStatus;

void EZI2C_ISR_ExitCallback()

{

    volatile uint8 temp = EZI2C_curStatus;//EZI2C_GetActivity();

    if(temp == EZI2C_STATUS_WRITE1)

    {

        //Application code here

    }

   

}

Best regards,

Hari

View solution in original post

0 Likes
Reply