Part Number: MSP430FR5994
Other Parts Discussed in Thread: LDC1614EVM, LDC1614
Hello everyone!
I'm try to control LDC1614EVM using my MSP430FR5994launchpad but without success in read mode.
Here is the test, when MSP read the LDC1614 manufacture_id, the LDC should answer 0x5449(MSB:0x54, LSB 0x49)
The IIC configure code is as fellows:
void IIC_init(void){
//set the I2C IO
GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P7, GPIO_PIN0+GPIO_PIN1, GPIO_PRIMARY_MODULE_FUNCTION);
EUSCI_B_I2C_initMasterParam iic_param = {0};
iic_param.selectClockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK;
iic_param.i2cClk = CS_getSMCLK();
iic_param.dataRate = EUSCI_B_I2C_SET_DATA_RATE_400KBPS;
iic_param.autoSTOPGeneration = EUSCI_B_I2C_NO_AUTO_STOP;
iic_param.byteCounterThreshold = 1;
EUSCI_B_I2C_initMaster(EUSCI_B2_BASE, & iic_param);
//set slave address
EUSCI_B_I2C_setSlaveAddress(EUSCI_B2_BASE, LDC_ADDRESS);
//enable IIC
EUSCI_B_I2C_enable(EUSCI_B2_BASE);
//clear IIC interrupt
EUSCI_B_I2C_clearInterrupt(EUSCI_B2_BASE, EUSCI_B_I2C_RECEIVE_INTERRUPT0 + EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT + EUSCI_B_I2C_NAK_INTERRUPT);
//
//Enable master interrupt
// EUSCI_B_I2C_enableInterrupt(EUSCI_B2_BASE, EUSCI_B_I2C_RECEIVE_INTERRUPT0);
while(EUSCI_B_I2C_isBusBusy(EUSCI_B2_BASE));
printf("I2C in Master mode initial finish!\r\n");
return;
}
after, when the key interrupt is detected,MSP read the LDC's manufacture_id,here is the read code.
uint16_t IIC_Read_Bytes(uint8_t RegAddr, uint8_t length){
i2c_rx_buf_len = length;
uint8_t data1,data2;
uint16_t data_test;
while(EUSCI_B_I2C_isBusBusy(EUSCI_B2_BASE));
EUSCI_B_I2C_setMode(EUSCI_B2_BASE, EUSCI_B_I2C_TRANSMIT_MODE);
EUSCI_B_I2C_masterSendSingleByte(EUSCI_B2_BASE, RegAddr);
//receive
EUSCI_B_I2C_setMode(EUSCI_B2_BASE, EUSCI_B_I2C_RECEIVE_MODE);
EUSCI_B_I2C_masterReceiveStart(EUSCI_B2_BASE);
while(EUSCI_B_I2C_isBusBusy(EUSCI_B2_BASE));
data1 = EUSCI_B_I2C_masterReceiveMultiByteNext(EUSCI_B2_BASE);
data2 = EUSCI_B_I2C_masterReceiveMultiByteFinish(EUSCI_B2_BASE);
EUSCI_B_I2C_masterReceiveMultiByteStop(EUSCI_B2_BASE);
EUSCI_B_I2C_masterIsStopSent(EUSCI_B0_BASE);
while(EUSCI_B_I2C_isBusBusy(EUSCI_B2_BASE));
data_test = data1<<8 | data2;
return data_test;
}
when I first push the button ,The oscillogram show as fellows:

the MSP continues to work,
PS : I used to trying debug step by step, it seems data1 = EUSCI_B_I2C_masterReceiveMultiByteNext(EUSCI_B2_BASE) return empty.
then I push the button again,The The oscillogram show as fellows:

Now MSP is Loop in -> while (!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) ;
ALSO, I try read LDC data with another way, as fellows:
uint16_t IIC_Read_Bytes(uint8_t RegAddr, uint8_t length){
i2c_rx_buf_len = length;
uint8_t data1,data2;
uint16_t data_test;
while(EUSCI_B_I2C_isBusBusy(EUSCI_B2_BASE));
EUSCI_B_I2C_setMode(EUSCI_B2_BASE, EUSCI_B_I2C_TRANSMIT_MODE);
EUSCI_B_I2C_masterSendSingleByte(EUSCI_B2_BASE, RegAddr);
//receive
EUSCI_B_I2C_setMode(EUSCI_B2_BASE, EUSCI_B_I2C_RECEIVE_MODE);
EUSCI_B_I2C_masterReceiveStart(EUSCI_B2_BASE);
while(EUSCI_B_I2C_isBusBusy(EUSCI_B2_BASE));
data1 = EUSCI_B_I2C_masterReceiveMultiByteNext(EUSCI_B2_BASE);
data2 = EUSCI_B_I2C_masterReceiveMultiByteNext(EUSCI_B2_BASE);
EUSCI_B_I2C_masterReceiveMultiByteStop(EUSCI_B2_BASE);
EUSCI_B_I2C_masterIsStopSent(EUSCI_B0_BASE);
while(EUSCI_B_I2C_isBusBusy(EUSCI_B2_BASE));
data_test = data1<<8 | data2;
return data_test;
}
The The oscillogram show as fellows:

they lost LSB again, But in this way, the MSP do not fall into the loop.
How can I get the data properly?
thank you for your attention and best regards!
