AnsweredAssumed Answered

I2C Master Driver Hanging on Kinetis K22.

Question asked by Donald Bosley on Oct 30, 2014
Latest reply on Oct 30, 2014 by Jorge_Gonzalez

Trying to use the I2C Master Driver in a Bare Metal application.

Currently when I use the I2C Master Driver I'm ending up here :

 

Default_Handler:

  b .

  .size Default_Handler, . - Default_Handler

 

Tracing the error backwards, this is the function sequence :

 

I2C_DRV_MasterSendDataBlocking calls I2C_DRV_SendAddress calls I2C_DRV_MasterWait calls OSA_SemaWait calls OSA_TimeGetMsec() calls LPTMR_HAL_GetCounterValue(uint32_t baseAddr):

 

static inline uint32_t LPTMR_HAL_GetCounterValue(uint32_t baseAddr)

{

    BW_LPTMR_CNR_COUNTER(baseAddr, 0);  /* Must first write to the CNR with any value */

    return (uint32_t)(BR_LPTMR_CNR_COUNTER(baseAddr) & 0xFFFFU);

}

 

Where:

/*! @brief Set the COUNTER field to a new value. */

#define BW_LPTMR_CNR_COUNTER(x, v) (HW_LPTMR_CNR_WR(x, (HW_LPTMR_CNR_RD(x) & ~BM_LPTMR_CNR_COUNTER) | BF_LPTMR_CNR_COUNTER(v)))

/*@}*/


The baseAddr is 04004000 which is correct for LPTMR, and I have verified the LPTMR is enabled (set up by OSA_Init, called in my main).

 

Anyone had this problem and been able to solve it? I will add some of my attempts to solve this as I work through it, but if anyone can point to a solution that would be cool also.

----

EDIT: From a hardware perspective, and I probably should have said this to begin with, the clocking and data are coming out of the pins correctly for the Address send, but then they hang low permanently.

I've tried just hooking to the scope and would think that after the I2C doesn't receive anything back it would reset high - at least that's the way it has worked on other chips I've used...

-----

EDIT II: Ran the i2c_rtos_ucosiii project successfully.

Outcomes