I've got a strange issue. I2C is working but randomly stopping transmission without an error message.
Hardware: CC3200LP + Adafruit Servo shield PCA9685 + 6k pullups on SDA and SCL.
Code:
Init i2c
...
/* Init code for I2C */ void I2C_start(unsigned int indexI2C){ I2C_Params_init(&i2cParams); i2cParams.bitRate = I2C_100kHz; i2cParams.transferMode = I2C_MODE_BLOCKING; i2cParams.transferCallbackFxn = NULL; i2c = I2C_open(indexI2C, &i2cParams); if (i2c == NULL) { System_abort("Error Initializing I2C\n"); } else { System_printf("I2C Initialized!\n"); System_flush(); } }
...
/* Code for multible PWM output settings */
... void Update_multiple_LEDs(uint16_t *OUTPUT_VALUES) { txBufferMulti[0] = 0x6; //LED0 register has to addressed. Auto increment is doing the rest for(i = 0; i < 8; i++){ u = i * 4 ; txBufferMulti[u+1] = 0x0; //on txBufferMulti[u+2] = txBufferMulti[u+1]>>8; //on txBufferMulti[u+3] = OUTPUT_VALUES[i]; //off txBufferMulti[u+4] = OUTPUT_VALUES[i]>>8;//off } i2cTransaction.writeBuf = txBufferMulti; i2cTransaction.writeCount = 33; i2cTransaction.readBuf = rxBuffer; i2cTransaction.readCount = 0; i2cTransaction.slaveAddress = PCA9685_1; if (!(I2C_transfer(i2c, &i2cTransaction))) { System_printf("I2C Bus fault\n"); System_flush(); } Task_sleep(10); }
...
main
...
Void i2cTask(){ System_printf("I2C Task started...\n"); System_flush(); uint16_t OUTPUT_ZEROVALUE_ARRAY[8] = {0,0,0,0,0,0,0,0}; uint16_t OUTPUT_VALUE_ARRAY_R[8] = {100,0,0,1000,2000,3000,4000,4095}; //PWM Values {Cnannel 0, Channel 1, Channel 3, ...} uint16_t OUTPUT_VALUE_ARRAY_G[8] = {0,100,0,1000,2000,3000,4000,4095}; //PWM Values {Cnannel 0, Channel 1, Channel 3, ...} uint16_t OUTPUT_VALUE_ARRAY_B[8] = {0,0,100,1000,2000,3000,4000,4095}; //PWM Values {Cnannel 0, Channel 1, Channel 3, ...} I2C_start(Board_I2C_TMP); PC9685_init(PWM_FREQUNCY); //I2C and PWM Frequency in Hz Update_multiple_LEDs(OUTPUT_ZEROVALUE_ARRAY); while (1) { Update_multiple_LEDs(OUTPUT_VALUE_ARRAY_R); Update_multiple_LEDs(OUTPUT_VALUE_ARRAY_G); Update_multiple_LEDs(OUTPUT_VALUE_ARRAY_B); }
The code is working and the first 8 PWMs are updated every 10ms. But is just stops after a while and there is no clock or data on the bus.
I'm new to ti-rtos + i2c...
Any idea what the issue is?
Thanks