Other Parts Discussed in Thread: HALCOGEN
Hello, I've created a simple program to send messages to a Temperature sensor (I'm not now using the I2C2 port for acknowledges):
CCS 7.0.0.00042
HALCoGen 04.07.01
void start(void) {
unsigned char data[8];
unsigned slave_address;
slave_address = 0x48;
unsigned char num_bytes = 1;
unsigned char num_count = 1;
unsigned char modifier = 0x80;
unsigned char set_stop = 1;
sciInit();
i2cInit();
i2cSetOwnAdd(i2cREG1, 1); //Own address
i2cSetSlaveAdd(i2cREG1, slave_address); // Slave address
i2cSetOwnAdd(i2cREG2, 2); //Own address
i2cSetSlaveAdd(i2cREG2, 1); // Slave address
do
{
sciReceive(sciREG1, 1, data); // poll for command to be received
data[0] = data[0] | modifier;
i2cSetCount(i2cREG1, num_count);
i2cSetStart(i2cREG1);
i2cSend(i2cREG1, num_bytes, data);
if (set_stop == 1) i2cSetStop(i2cREG1);
i2cSetMode(i2cREG1,I2C_MASTER);
}
while (TRUE);
} // end main()
The calls may not be in strict accordance wit the user guide but it was the only way I could get repeatable operation.
With the values as initialised, I can send repeated single byte messages (when the sensor command expects it) via keyboard entry.
If I use debug to modify the num_bytes and num_count to 3, I can send one string of the correct command byte for a 3-byte message - this is with set_stop set to 1 or zero.
It appears to terminate correctly but I cannot then get any activity on either line for a further command, unlike the single command mode.
Any suggestions appreciated.
Thanks