Other Parts Discussed in Thread: LP5024,
Hi,
I am looking to get some help on using the MSP430G2553 with I2C. I am trying to change a specific register on a peripheral (LP5024) but don't quite understand how this can be accomplished using an MSP430. I have found the following documentation on how this can be accomplished:
What I don't understand is how this can be translated into code. I have been looking at the examples and none of them quite seem to fit into this situation.
One question that I have is regarding step 2 and the MSP430 buffer UCB0I2CSA. When transmitting a sequence of data, does this automatically get sent at the beginning or do I need to do it manually. For example, say I wanted to write 0xFF to register 0x00 of a peripheral with address 0x88. Do i need to manually send
const unsigned char TxData ={ 0x00 , 0xFF }; // Table of data to transmit
or
const unsigned char TxData ={ 0x88, 0x00 , 0xFF }; // Table of data to transmit
?
If it is the second option, what is the purpose of the UCB0I2CSA buffer?
I have been using the code msp4302xx3_uscib0_i2c_08.c as the framework for my work. If I want to change two separate registers on my peripheral, can I simply duplicate the code inside the main loop like this?
while (1)
{
PTxData = (unsigned char *)TxData1; // TX array start address
TXByteCtr = sizeof TxData1; // Load TX byte counter
while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
__bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts
// Remain in LPM0 until all data
// is TX'd
PTxData = (unsigned char *)TxData2; // TX array start address
TXByteCtr = sizeof TxData2; // Load TX byte counter
while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
__bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts
// Remain in LPM0 until all data
// is TX'd
}
Thank you for your help!
Kathleen