This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS470 I2C communication problem

Hi guys

The datasheet of the slave device (HMC6343) provides the following steps for communication :

1 Apply power

2 Wait 500 millisecond for device

3 Send 0x30 and 0x50 to command the Data to be clocked out next

4 Wait at least 1 millisecond to process the command

5 Send 0x33 and clock back six more response bytes from HMC6343.

6 Repeat step 3 - 5 every 200 millisecond.

My code is like this :

GCR = 0x08;

I2C1PSC = 2;    // Module clock frequency
I2C1CKL = 45; // Low clock period
I2C1CKH = 45; // High clock period

I2C1OAR = 0x56; // Set TMS470's Own address to 0x56
I2C1IMR = 0;    // Disable I2C Interrupt

I2C1CNT = 3; // Number of byte transactions between I2C Start and Stop
I2C1SAR = 0x32; // Set address of slave to 0x32

I2C1PFNC = 0;   // Pins function as SDA and SCL pins
I2C1DIR |= 0x0C; // Set I2C Pin direction
  
I2C1SR = 0;     // Master mode, Transmitter/Receiver (bit 14)

I2C1DXR = 0x32; // Load data Address
do { } while ((I2C1SR & 0x0010) == 0x0010 ); //wait for acknowledgement
I2C1MDR = 0x6E20;   //
do { } while ((I2C1SR & 0x0010) == 0x0010 ); //wait for acknowledgement

I2C1DXR = 0x50;  //load command
do { } while ((I2C1SR & 0x0010) == 0x0010 ); //wait for acknowledgement
delay();

I2C1DXR = 0x33;
do { } while ((I2C1SR & 0x0010) == 0x0010 ); //wait for acknowledgement

I2C1CNT = 0x06;    //counter for receive data
I2C1MDR = 0x6C20; // Receive data byte
do { } while ((I2C1SR & 0x0004) == 0x0004); // Wait to receive data
I2C1DRR = 0;  //reset the data receive register
Yawh = ((I2C1DRR) & 0x00FF) << 8;
do { } while ((I2C1SR & 0x0004) == 0x0004); // Wait to receive data
Yawl = ((I2C1DRR) & 0x00FF);
do { } while ((I2C1SR & 0x0004) == 0x0004); // Wait to receive data
Pitchh = ((I2C1DRR) & 0x00FF) << 8;
do { } while ((I2C1SR & 0x0004) == 0x0004); // Wait to receive data
Pitchl = ((I2C1DRR) & 0x00FF);
do { } while ((I2C1SR & 0x0004) == 0x0004); // Wait to receive data
Rollh = ((I2C1DRR) & 0x00FF) << 8;
do { } while ((I2C1SR & 0x0004) == 0x0004); // Wait to receive data
Rolll = ((I2C1DRR) & 0x00FF);

I2C1MDR = 0x4E20; // Transmit STOP Bit
I2C1SR &= ~0x1000;

...

However the debugging stops at the point to wait for acknowledgement. Can anyone tell what's wrong with my code??

Thanks a lot

Rui

  • Hi Rui

    Could you please let us know what device you are working with?

    Please be aware that the TMS470R1x series is not recommended for new designs.  Please see the full 'NRDN' notice here.

    Soon TI will be launching the new TMS470M series of microcontrollers.  This series will feature greater ARM CPU performance and a similar peripherial set to the TMS470R1 Series of microcontrollers.  Please come back soon for more information about the TMS470M Series of microcontrollers.  The product preview for the first two microcontrollers in the TMS470M series is available here: TMS470MF0660x - SPNS157. The TMS470M Series Technical Reference Manual is available here: TMS470M TRM.

    Best Regards
    Prathap

     

  • Hi Rui,

    I found a CCS3.3 TMS470 I2C ARM7 test project which configures the module as Master receive - using polling method. I think this will be useful to you.

    8664.I2C_Master_Rx_Polling.zip

    Best Regards
    Prathap

     

     

  • Hi Prethap

    Thanks for your suggestion. I have found the problem. The slave needs 7 bit add + 1 bit R/W. The R/W bit is already set by master control register. Therefore the master just need to send 7 bit add without the R/W bit to slave.

    Rui