PSoC 5LP EZI2C Write

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

cross mob
DavideM
Level 3
Level 3
10 replies posted 5 replies posted 5 questions asked

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
1 Solution
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

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
1 Reply
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

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

0 Likes