Is this a bug in Simple Library

#include "simpletools.h"  
#include "mstimer.h"


i2c *IQ_I2C;
int main()
{
  i2c_open(IQ_I2C,3,2,1);
  mstime_set(0);
  mstime_start();
  printf("Start:");
    while(mstime_get()<5000)
  {
    pause(500);
    printf("Time:%d\n",mstime_get());
  }
  printf("Close.");
}




the results shows below:

Start:
Time: 0
Time: 0
Time: 0
Time: 0
Time: 0
Time: 0
Time: 0


Comments

  • 2 Comments sorted by Date Added Votes
  • Your call to i2c_open is causing the problem. The first parameter is a pointer to an i2c struct. Your pointer is not initialized, and is most likely pointing to location zero. You should declare IQ_I2C as "i2c IQ_I2C", and then call i2c_open with "i2c_open(&IQ_I2C,3,2,1);".
  • Dave Hein wrote: »
    Your call to i2c_open is causing the problem. The first parameter is a pointer to an i2c struct. Your pointer is not initialized, and is most likely pointing to location zero. You should declare IQ_I2C as "i2c IQ_I2C", and then call i2c_open with "i2c_open(&IQ_I2C,3,2,1);".

    Thank you, problem solved.
Sign In or Register to comment.