AnsweredAssumed Answered


Question asked by Lee Penn on Jul 26, 2013
Latest reply on Jul 31, 2013 by Lee Penn



     I am using the MQX 4.0 with Codewarrior for use on the K70. When I initialize I2C0 all is fine, I added the I2C1 initialization code to the BSP, see below. But when I try to initialize the I2C1 it causes an interrupt before the initialization can complete. I can initialize the I2C1 and communicate using a PE program. Could there be a part in the BSP for the twr k70 that is configuring the pins I need for I2C1 before it is called, and then causing my interrupt?


_mqx_int _bsp_i2c_io_init
    uint_32 dev_num

    PORT_MemMapPtr  pctl;
    SIM_MemMapPtr sim = SIM_BASE_PTR;

    switch (dev_num)
        case 0:
            pctl = (PORT_MemMapPtr)PORTE_BASE_PTR;

            pctl->PCR[18] = PORT_PCR_MUX(4) | PORT_PCR_ODE_MASK;
            pctl->PCR[19] = PORT_PCR_MUX(4) | PORT_PCR_ODE_MASK;

            sim->SCGC4 |= SIM_SCGC4_IIC2_MASK ;

        case 1: //I2C1, LP Added 7/25/13
            pctl = (PORT_MemMapPtr)PORTF_BASE_PTR;

            pctl->PCR[3] = PORT_PCR_MUX(4) | PORT_PCR_ODE_MASK ; // PTF3, I2C1_SDA, LP Added 7/25/13
            pctl->PCR[2] = PORT_PCR_MUX(4) | PORT_PCR_ODE_MASK; // PTF2, I2C1_SCL, LP Added 7/25/13

            sim->SCGC4 |= SIM_SCGC4_IIC2_MASK ;

            /* Do nothing if bad dev_num was selected */
            return -1;
    return MQX_OK;