EstoyintentandoquemiMSP430hableconunsensorMPU-6050atravésdeI2C.Sialguienpuederevisarestehardwareyversihayunproblemaallí,teloagradecería.Lasresistenciasestánconectadasalrielrojo.Ahoramismoson2.2k,perotambiénheprobado8ky10k.
Yelcódigosesigueenganchandoenlalíneaqueseindicaacontinuación.Bastantesegurodequeelesclavonoestáenviandounaseñaldereconocimiento:
while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent (UCTXSTP auto clears after STOP is sent)
UCB0CTL1 |= UCTR + UCTXSTT; // I2C start condition with UCTR flag for transmit
while((IFG2 & UCB0TXIFG) == 0); //UCB0TXIFG is set immidiately (UCB0TXIFG is set to indicate TXBUF is ready for more data)
UCB0TXBUF = registerAddr; //write registerAddr in TX buffer
__delay_cycles(1000);
while((IFG2 & UCB0TXIFG) == 0); // CODE GETS STUCK HERE.
//wait until TX buffer is empty and transmitted
UCB0CTL1 &= ~UCTR; // Clear I2C TX flag for receive
UCB0CTL1 |= UCTXSTT + UCTXNACK; // I2C start condition with NACK for single byte reading
while (UCB0CTL1 & UCTXSTT); // Start condition sent? RXBuffer full?
receivedByte = UCB0RXBUF;
UCB0CTL1 |= UCTXSTP; // I2C stop condition
return receivedByte;