Dear community,
I've been working with the I2C, i use the USI I2C Code Library, my micro and sensor works together to initialize and writing data, but when is time to read just break and doesn't work any more
i though that may be doesn't work because the interruptions are disable but when I add after this break line
??enable?interrupt(): is breaker too but in this line, i don't understand what happen could you help me to understand and correct the mistake????
void main(void)
{
TI_USI_I2C_MASTER
WDTCTL = WDTPW+WDTHOLD; // disable Watchdog
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
{
while(1); // If calibration constants erased
// do not load, trap CPU!!
}
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P1DIR |= 0x01;
P1OUT = 0;
// Initialize USI module, clock ~ SMCLK/128
TI_USI_I2C_MasterInit(USIDIV_5+USISSEL_2+USICKPL, StatusCallback);
/* Acknowledge polling function - LED blinks continuously until slave device
provides an ACK
TI_USI_I2CSelect(unsigned char SlaveAddress) */
while(TI_USI_I2CSelect(0x0A))
{
P1OUT ^= 0x01; // Toggle LED
for (i = 0; i < 0x3000; i++); // Delay
}
P1OUT =0; // Slave acknowledged, LED off
/*Transmit data to the slave MSP430 device
TI_USI_I2CWrite(SlaveAddress, Length, Multi, TxData) */
__disable_interrupt();
TI_USI_I2CWrite(0x0A, 1, 0,TxData);
__bis_SR_register(LPM0_bits + GIE);
/*Read data from the slave MSP430 device
TI_USI_I2CRead(SlaveAddress, Length, Multi, RxData) */
__disable_interrupt();
TI_USI_I2CRead(0x0A, 35, 0,RxData);
__bis_SR_register(LPM0_bits + GIE);
// check data for validity
for (j = 0;j<35;j++)
{
if (RxData[j]!=j)
{
while(1); // data invalid
}
}
P1OUT |= 0x01; // data valid, LED on
while(1); // program ends here
}
int StatusCallback(unsigned char c)
{
return TI_USI_EXIT_LPM; // exit active for next transfer
}
thanks for your help and time, regards