Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

I^2C Sending to all registers? "MAX44009"

$
0
0

I'm currently working one setting up the MAX44009 with the stellaris-lm3s6965.

My problem is that each time i send to a register on the  MAX44009 it overwrites every single register with the value send.

It dosn't seem like the sending and the receiving is the problem since it works perfectly with other i^2C devices.

Example:

 When i set register 0x02 ( Configuration register ) to have a
 value of 0000 0011 it also sets this value on all the other
 registers.

 So when i:

 // Function, Register, DataToSend, SlaveAddresse
 I2CGenSingle(SEND,0x02,0x03,0x4A);
 DataL = I2CGenSingle(RECEIVE,0x01,0x00,0x4A);
 DataH = I2CGenSingle(RECEIVE,0x02,0x00,0x4A);

CODE for sending and receiving.

int I2CGenSingle (int Function, int Register, int Data, int Slave)
{
int i2cdata = 0;
switch (Function)
{
case SEND:

I2CMasterSlaveAddrSet(I2C0_MASTER_BASE, Slave, false); // false=write / true=read
I2CMasterDataPut(I2C_MASTER_BASE, Register); // Hex value first 4 bits used for CTRL data, last 4 bits forms the first 4 bits of the 12 bit word to determine DAC voltage
I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START);
while (I2CMasterBusy(I2C0_MASTER_BASE));
I2CMasterDataPut(I2C_MASTER_BASE, Data); // Hex value forms the last 8 bits of the 12 bit word to determine DAC voltage
I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while (I2CMasterBusy(I2C0_MASTER_BASE));
I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_STOP );
while (I2CMasterBusy(I2C0_MASTER_BASE));
// A short delay.
SysCtlDelay(80000);

break;
case RECIEVE:
i2cdata = 0;
// DAC address = 1001100 therefore Hex value = 0x4C
I2CMasterSlaveAddrSet(I2C0_MASTER_BASE, Slave, false);

I2CMasterDataPut(I2C_MASTER_BASE, Register);
I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND);
// while (I2CMasterBusy(I2C0_MASTER_BASE));

I2CMasterSlaveAddrSet(I2C0_MASTER_BASE, Slave, true);
I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
while (I2CMasterBusy(I2C0_MASTER_BASE));
i2cdata = I2CMasterDataGet(I2C0_MASTER_BASE);
while (I2CMasterBusy(I2C0_MASTER_BASE));
// A short delay.
SysCtlDelay(80000);
break;

}
return i2cdata;

datasheet for "MAX44009"

http://datasheets.maximintegrated.com/en/ds/MAX44009.pdf


 DataL and DataH will be the same values even though i only wrote
 to the configuration register.
 Any help will be most welcome


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>