Hi Ben,
The master mode is what I need.
What I am trying to do is communicate with a Smart Battery over the SMBUS. The battery can be a master for event driven messages, however it will act as a slave when polled for data. That is how I intend to use it.
The battery pack is the nl2044hd22 manufactured by Inspired Energy (
http://www.inspired-energy.com). From their data sheet the read word protocol is below.
http://www.inspired-energy.com/Standard ... NL2044.htm NL2044HD22 (High Current Discharge version) Engineering data sheet, page 12.
____________________________
3.3.4.2.Read Word
Reading data is slightly more complex than writing data. First the host must write a command to the slave device.
Then it must follow that command with a repeated start condition to denote a read from that device's address. The
slave then returns two bytes of data.
Note that there is not a stop condition before the repeated start condition, and that a "Not Acknowledge" signifies
the end of the read transfer.
I couldn't figure out how to paste in the "Read Word" bit definition image from the data sheet, so here goes:
Bits Descritpion
1 Start
7 Battery Address
1 Write
1 Ack
8 Command Code
1 Ack
1 Start
7 Battery Address
1 Read
1 Ack
8 Data Byte Low
1 Ack
8 Data Byte High
1 Ack
Read Word Protocol
SMBus Host (master) Smart Battery (slave)
____________________________________________
What I have tried is:
1. MI2C_Init
2. MI2C_Start
3. MI2C_Transmit_Byte (0x16 is the address with the LSB=0)
4. MI2C_Transmit_Byte (0x09 is the Command Code for reading the voltage)
5. MI2C_Start_Restart
6. MI2C_Transmit_Byte (0x17 is the address with the LSB=1)
7. MI2C_Receive_Btye (I set the β€Last(BYTE)=1 and a variable β€LOWβ€ for the return value)
8. MI2C_Receive_Btye (I set the β€Last(BYTE)=0 and a variable β€HIGHβ€ for the return value)
9. MI2C_Stop
I am receiving ACKs when addressing the battery and sending the command code, however, I can not receive any data.
I’m not sure if the problem is with sending the command code or the receive command.
My understanding of communicating with a slave is that the master generates the clock on the SCL line and the slave returns the data during this period on the SDA line.
Does the PIC generate the clock during the β€MI2C_Receive_Btyeβ€ command?
What is the purpose of the β€Last(BYTE)β€ field in the β€MI2C_Receive_Btyeβ€ command?
Do you have any thoughts on my communication problem? Any help would be much appreciated.
Thank you,
Ralph