Brad Stewart

Why is there a pause() in I2C routines?

Discussion created by Brad Stewart Employee on May 17, 2013
Latest reply on Aug 31, 2014 by Jia Guo

I've been working with KL25.

I've need to read I2C data from one of our sensors.  I used the routines provided in the examples (KL25_SC Rev 6).

The i2c.c code has a small delay function called pause() which does about 40 NOP instructions (see below).

This function is called after i2c_Stop() in the I2CWriteRegister and I2CReadRegister functions.

If you don't call pause(), the system will not function.

 

In looking at the Processor Expert code, there is no delay function.

 

So what's going on?

 

thanks,

 

// this delay is very important, it may cause w-r operation failure.

static void pause(void)

{

    int n;

    for(n=0; n<40; n++);

      #ifndef CMSIS

  asm ("NOP"); // Toggle LED1

  #else

  __nop();

  #endif

}

Outcomes