Other Parts Discussed in Thread: LP5036, MSP430F247, TMS320F28035, LP5569
At the end, I program the I2c without the library functions - and everything seems to work fine - though it sometimes gets "stuck".
This is for a 24/7 device - really quite simple - and one of the major functions is the blinking LEDs.
I put in a check that if the I2C times out, the I2C should be reset. This helps most of the time - and is almost imperceptible.
BUT after a few hours of running, the LEDs stop blinking and remain on constantly, even though the rest of the device's functions work well - communication over RS485, etc.
What could be the reason? How can I diagnose that the LEDs are constantly ON - is there a register I could read to make sure that the LEDs and OFF when they should be and ON when they should be?
bool LP5036_bankColor(BYTE red, BYTE green, BYTE blue) { bool ret = 1; ret = LP5036_write2_Byte( LP5036_BANK_A_COLOR, red, green); if (ret != STATUS_SUCCESS) { Reset_I2C(); } return ret; } bool LP5036_write2_Byte(BYTE reg, BYTE data1, BYTE data2) //, BYTE data3) { WORD timeout = 1000; //Transmit Data to slave // UCB1I2CSA = LED_I2C_SLAVE_ADDR; // don't need - this is default UCB1IFG &= ~(UCTXIFG + UCRXIFG); // Clear any pending interrupts UCB1CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition while(!(UCB1IFG & UCTXIFG) && --timeout); //Poll for transmit interrupt flag. if(timeout == 0) //Check if transfer timed out { return (STATUS_FAIL); } UCB1TXBUF = reg; while(!(UCB1IFG & UCTXIFG) && --timeout); //Poll for transmit interrupt flag. if(timeout == 0) //Check if transfer timed out { return (STATUS_FAIL); } UCB1TXBUF = data1; while(!(UCB1IFG & UCTXIFG) && --timeout); //Poll for transmit interrupt flag. if(timeout == 0) //Check if transfer timed out { return (STATUS_FAIL); } UCB1TXBUF = data2; while(!(UCB1IFG & UCTXIFG) && --timeout); //Poll for transmit interrupt flag. if(timeout == 0) //Check if transfer timed out { return (STATUS_FAIL); } UCB1CTL1 |= UCTXSTP; // Send stop condition return STATUS_SUCCESS; } void Reset_I2C(void) { UCB1CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, Enable SW reset UCB1CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode UCB1CTL1 &= ~UCSWRST; // Clear SW reset, resume operation }