AnsweredAssumed Answered


Question asked by Sergio Alejandro González on Apr 12, 2016
Latest reply on Apr 13, 2016 by Sergio Alejandro González

Sorry to bother but the example "i2c_interrupt_transfer.c" is not working on my K22FN1M0 on a custom board. I believe now, that the problem is not in the example itself, but rather than the KDS.


I've tracked down the problem to the function in the KDS on file "fsl_i2c.c" and the function I2C_MasterTransferCreateHandle:



    void I2C_MasterTransferCreateHandle(I2C_Type *base,

                                        i2c_master_handle_t *handle,

                                        i2c_master_transfer_callback_t callback,

                                        void *userData)




        uint32_t instance = I2C_GetInstance(base);


        /* Zero handle. */

        memset(handle, 0, sizeof(*handle));


        /* Set callback and userData. */

        handle->completionCallback = callback;

        handle->userData = userData;


        /* Save the context in global variables to support the double weak mechanism. */

        s_i2cHandle[instance] = handle;


        /* Save master interrupt handler. */

        s_i2cMasterIsr = I2C_MasterTransferHandleIRQ;


        /* Enable NVIC interrupt. */




there, the instance is 0 and the irq is set, but the, with the following equate, I don't think is working at all:


    s_i2cMasterIsr = I2C_MasterTransferHandleIRQ;


...since the handle is never called!.



The problem is that "I2C_TransferCommonIRQHandler" is never called and so, no handler is available for the interrupt and the code, oboiusly, ends in:


    // handler is not present in the application code.

    void __attribute__ ((section(".after_vectors")))



      while (1)





Other examples work for me and the I2C interrupt is working in another custom work so no problems there. My development system is on windows eclipse and GCC with GNU Tools ARM Embedded (4.8 2014q2) and also tested on a more modern 5.2 2015q4 and GDB 7.1.