Other Parts Discussed in Thread: MSP430F2012
Hi all,
If anyone has looked at TI's example code for I2C protocol (MSP430F2012 to be specific), they have seen this helper function below:
void Master_Receive(void){
volatile unsigned int i;
Setup_USI_Master_RX();
USICTL1 |= USIIFG; // Set flag and start communication
LPM0; // CPU off, await USI interrupt
for (i = 0; i < 5000; i++); // Delay between comm cycles
}
After entering LPM0, multiple interrupts are created, and a case statement in the ISR controls sending data, receving ACK/NACK and all that good stuff. However, I was wondering what the highlighted line is needed for in the function. In particularly, it is really slowing my writes and reads down, and it seems like my writes and reads work properly when I take it out entirely. Can anyone explain what the for loop is needed for in this case? And if my code appears to be working right now without it, is there a chance that it will not work later on? Does it depend on how many bytes I transfer in a single read/write? For example, the most I currently have to transfer over I2C at any one time is 4 bytes. Any help or insight would be greatly appreciated!
Thanks,
Matt