3 Replies Latest reply on Apr 25, 2016 3:10 AM by user_1377889

    I2C Interrupt operation

    wbasser_1635821

      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.

        • 1. Re: I2C Interrupt operation
          user_1377889

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

             

           

             

          Bob

          • 2. Re: I2C Interrupt operation
            wbasser_1635821

            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.

            • 3. Re: I2C Interrupt operation
              user_1377889

              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