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