AnsweredAssumed Answered

Initializing MAX11068 with MC9S12DG256CFU - Processor Expert - I2C Bean

Question asked by Kevin Burkett on Feb 6, 2012
Latest reply on Feb 17, 2012 by Kevin Burkett

I am using Codewarrior version 5.9.0 and Processor Expert Version 3.02 to program an MC9S12DG256CFU to control the MAX11068 battery monitoring chip.  I have never used I2C before and I have limited experience working with these microcontrollers. 

 

I would like to use the I2C functions provided by the processer expert bean, but I am having trouble intializing the MAX11068.  I assume the connections are correct because the I2C functions are returning 0x00 for there error code.  Page 58 of the MAX11068 outlines the two initialization sequences I am working on called "HELLOALL" and "ROLLCALL". 

 

Issues:

 

1. With the HELLOALL command all I need to do is send one byte on the data line for the devices to start assigning themselves addresses.  Here is the basic code I am using:

 

    helloByte=0xE0;   //This is the command Byte that assigns the first device address
    error[0] = EI2C1_SelectSlave(helloByte);  //There is no slave address yet, so assigning command byte.
    error[0] = EI2C1_SendChar(0x00);

    error[0] = EI2C1_SendStop();


I received an acknowledge, but I am not sure this code is working because I send that zero byte.  Is there any way to just send the command byte?

 

2. With the ROLLCALL command I need to be able to perform a restart to change the master from transmitting to receiving..  There doesn't seem to be anyway of doing this, so I have been trying to just set the RSTA bit of the IBCR register myself. 

 

    error[0]=EI2C1_SelectSlave(BRDADDRW); //Broadcast set to write
    error[0]=EI2C1_SendChar(0x01);       //Command For Device Address Register
    IBCR &= ~0x0C;   //~00001100 = 11110011 //Set Restart and Auto Ack
   error[0]=EI2C1_RecvBlock(all_addresses,2,rec);  //I only have one device connected so only 2 bytes should be received

 

Is there anyway to perform a restart with the Processor Expert functions?  Other than setting the restart bit should I be setting any other bits or will the Bean functions handle the rest?     

 

Thanks

Outcomes