I2C Interrupt operation

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

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Scenariio:

   

I want to receive a message from the I2C and upon an interrupt, process the received message, this means that the I2C is in slave mode.

   

I have insured that the message is actually coming in my using a poll method in an idle loop to monitor the status and upon a SCB_I2C_SSTAT_WR_CMPLT status indication, process the message.  This works.

   

 

   

However, when I register the custom interrupt handler and process the SCB_INTR_SLAVE_I2C_WRITE_STOP interrupt source, there is no data in the receive buffer.  

   

Is there someway to force the data to be copied into the buffer upon this interrupt.

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Two possible solutions.

   

Using Macro Callback. This is explained in Creator help. Modify CyCallback.h file:
insert a #define I2CSlave_I2C_ISR_EXIT_CALLBACK and declare a function I2CSlave_I2C_ISR_ExitCallback() that will be called just before the interrupt handler is exited.

   

 

   

Polling (as before). Serial communication is comparably slow, so just setting a flag which is checked and acted upon in the main loop usually is fast enough.

   

 

   

Bob

View solution in original post

0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I cannot see that you issued a I2C_SCB_SetSlaveInterruptMode(). Don't know if that changes behavior:

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I actually had that code and found it un-necessary.  I get the interrupt, but when I go to get the data size of the buffer, the function returns 0.  I think this might have something to do with the custom interrupt being called first and then normal processing is performed after the return.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Two possible solutions.

   

Using Macro Callback. This is explained in Creator help. Modify CyCallback.h file:
insert a #define I2CSlave_I2C_ISR_EXIT_CALLBACK and declare a function I2CSlave_I2C_ISR_ExitCallback() that will be called just before the interrupt handler is exited.

   

 

   

Polling (as before). Serial communication is comparably slow, so just setting a flag which is checked and acted upon in the main loop usually is fast enough.

   

 

   

Bob

0 Likes