Other Parts Discussed in Thread: FDC1004
Hi,
Apologies if this has been asked on here before but I couldn't find a specific answer.
Firstly, I am new to MSP430, I've only previously worked with ST Arm MPUs for about 6 months.
I am trying to use I2C to communicate with the FDC1004 capacitance sensing chip. I have been looking at the Driverlib examples, and there is one thing that doesn't seem to make an sense to me.
In the examples, TX functions have a parameter, like the following filled with "transmitData". Initially I thought this was the data that you want to send to the slave. The problem is then, how do you specify what address to write to in the slaves registry?
EUSCI_B_I2C_masterSendSingleByte(EUSCI_B0_BASE, transmitData);
For reference, this is the inside of that function
void EUSCI_B_I2C_masterSendSingleByte (uint16_t baseAddress, uint8_t txData ) { //Store current TXIE status uint16_t txieStatus = HWREG16(baseAddress + OFS_UCBxIE) & UCTXIE; //Disable transmit interrupt enable HWREG16(baseAddress + OFS_UCBxIE) &= ~(UCTXIE); //Send start condition. HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTR + UCTXSTT; //Poll for transmit interrupt flag. while (!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) ; //Send single byte data. HWREG16(baseAddress + OFS_UCBxTXBUF) = txData; //Poll for transmit interrupt flag. while (!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) ; //Send stop condition. HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTXSTP; //Clear transmit interrupt flag before enabling interrupt again HWREG16(baseAddress + OFS_UCBxIFG) &= ~(UCTXIFG); //Reinstate transmit interrupt enable HWREG16(baseAddress + OFS_UCBxIE) |= txieStatus; }
According to another question on here, it seemed like in the example, transmitData is set at 0x01 and is actually the pointer to the register to write to. However, if this is the case, then what is the data that is sent to it?
Apologies if this is a stupid question. Maybe I am lacking understanding of I2C.
Thanks,
Damien