Post Go back to editing

TWI/I2C 21489 C code example

Hi,

I'm trying to develop a link between the ADSP 21489 and ADT7411. I have to use the I2C protocol. Could someone point me to a C code example demonstrating an I2C transaction for the ADSP 21489.


Thanks!

Parents
  • Hi Jeyanthi,

    Thanks again for your response. I'm trying to write to and read from a Analog Devices Temperature Sensor. The file I attached in previous post was for attempting to read a register from Sensor. Let me explain, what I was attempting to do. On the ADT7411 Manual,  page 30, It describes steps to be able to read a register from sensor "Writing to the Address Pointer Register for a Subsequent Read: To read data from a particular register, the address pointer register must contain the address of that register. If it does not, the correct address must be written to the address pointer register by performing a single-byte write operation, as shown in Figure 34. The write operation consists of the serial bus address followed by the address pointer byte. No data is written to any of the data registers. A read operation is then performed to read the register." Since the read is essentially a write and then a read, I decided to focus on getting the write working first (please see attached file). For the write, I set the device (sensor) address and then write the register address as per instructed by the Temperature Sensor manual "Writing Data to a Register: All registers are 8-bit registers so only one byte of data can be written to each register. Writing a single byte of data to one of these read/write registers consists of the serial bus address, the data register address written to the address pointer register, followed by the data byte written to the selected data register"

    The problem: I'm trying to write 1 byte to the temperature sensor (fast mode) and a specific register in the sensor. I'm polling until the transmission is successful. No data is being transmitted. After setting the master mode adress and writing sensor register, I enable transfer and it gets stuck at the  while(*pTWIFIFOSTAT & TWITXS) {}; When I look at Visual DSP 5.0 TWI Registers TWIFIFOSTAT is 1 and TWITXS is 1. Data is not transferred. Do you have any recommendations ?

    Thanks for your help!

    Deco

Reply
  • Hi Jeyanthi,

    Thanks again for your response. I'm trying to write to and read from a Analog Devices Temperature Sensor. The file I attached in previous post was for attempting to read a register from Sensor. Let me explain, what I was attempting to do. On the ADT7411 Manual,  page 30, It describes steps to be able to read a register from sensor "Writing to the Address Pointer Register for a Subsequent Read: To read data from a particular register, the address pointer register must contain the address of that register. If it does not, the correct address must be written to the address pointer register by performing a single-byte write operation, as shown in Figure 34. The write operation consists of the serial bus address followed by the address pointer byte. No data is written to any of the data registers. A read operation is then performed to read the register." Since the read is essentially a write and then a read, I decided to focus on getting the write working first (please see attached file). For the write, I set the device (sensor) address and then write the register address as per instructed by the Temperature Sensor manual "Writing Data to a Register: All registers are 8-bit registers so only one byte of data can be written to each register. Writing a single byte of data to one of these read/write registers consists of the serial bus address, the data register address written to the address pointer register, followed by the data byte written to the selected data register"

    The problem: I'm trying to write 1 byte to the temperature sensor (fast mode) and a specific register in the sensor. I'm polling until the transmission is successful. No data is being transmitted. After setting the master mode adress and writing sensor register, I enable transfer and it gets stuck at the  while(*pTWIFIFOSTAT & TWITXS) {}; When I look at Visual DSP 5.0 TWI Registers TWIFIFOSTAT is 1 and TWITXS is 1. Data is not transferred. Do you have any recommendations ?

    Thanks for your help!

    Deco

Children
No Data