Other Parts Discussed in Thread: HALCOGEN
Hello,
I have a problem using I2C. I am trying to send data from the TMS570 (master mode) to a STS-35, a slave digital temperature sensor. However, the MCU does not send data. I used the examples of HALCoGen to use it.
The code is as follows:
//STS35 measurement
uint8_t tpu = 0;
for(i = 0; i<255; i++)
for (tpu = 0; tpu<5; tpu++);
/* Configure address of Slave to talk to */
i2cSetSlaveAdd(i2cREG1, STS35_Address);
sciSend(scilinREG, 22, (unsigned char *)"I2C Slave configured\r\n");
/* Set direction to Transmitter */
/* Note: Optional - It is done in Init */
i2cSetDirection(i2cREG1, I2C_TRANSMITTER);
sciSend(scilinREG, 41, (unsigned char *)"I2C Direction to transmitter configured\r\n");
/* Configure Data count */
/* Data Count ( Word Address) */
i2cSetCount(i2cREG1, STS35_bsize);
sciSend(scilinREG, 27, (unsigned char *)"I2C Data Count configured\r\n");
/* Set mode as Master */
i2cSetMode(i2cREG1, I2C_MASTER);
sciSend(scilinREG, 28, (unsigned char *)"I2C Master mode configured\r\n");
/* Set Stop after programmed Count */
i2cSetStop(i2cREG1);
sciSend(scilinREG, 25, (unsigned char *)"I2C Stop bit configured\r\n");
/* Transmit Start Condition */
i2cSetStart(i2cREG1);
sciSend(scilinREG, 26, (unsigned char *)"I2C Start bit configured\r\n");
/* Transmit DATA_COUNT number of data in Polling mode */
i2cSend(i2cREG1, STS35_bsize, TX_PACK);
sciSend(scilinREG, 16, (unsigned char *)"I2C sent bytes\r\n");
/* Wait until Bus Busy is cleared */
while(i2cIsBusBusy(i2cREG1) == true);
sciSend(scilinREG, 22, (unsigned char *)"I2C bus Busy cleared\r\n");
/* Wait until Stop is detected */
while(i2cIsStopDetected(i2cREG1) == 0);
sciSend(scilinREG, 19, (unsigned char *)"I2C Stop detected\r\n");
/* Clear the Stop condition */
i2cClearSCD(i2cREG1);
sciSend(scilinREG, 18, (unsigned char *)"I2C Stop cleared\r\n");
/* Simple Dealay before starting Next Block */
/* Depends on how quick the Slave gets ready */
for(i = 0; i<255; i++)
for (tpu = 0; tpu<40; tpu++);
The program remains in /* Wait until Stop is detected */ waiting for a Stop bit. I tried to measure the frame with my OSC but I could not detect any bit on SDA or SCLK.
Thank you so much.
Regards,
Leandro
