Hi,

I've used the above chip in several projects before, but have noticed a small issue with a current project as the code is writing to the PCA chip each time in the loop and I think it's causing the flicker in the LEDs on the output pins of the PCA chip.

I have the following section of code repeated for each of the 16 channels

Code:
If Counter1 => CH1_on_Time and counter1 < CH1_off_time then                     ' check to see if the time in minutes since midnight matches the Channel on time
CH1_PWM  = fadeset1                                                             ' and of so set the PWM value (0 to 4095) to match the fadeset value (also 0 - 4095)
endif                                                                           
If Counter1 => CH1_off_Time or Counter1 < CH1_on_time then                      ' check to see if the time in minutes since midnight matches the channel off time
CH1_PWM  =0                                                                     ' and if it does, then set the PWM value to 0, this turning the channel off
endif
The comments are self explanatory. At the end of the main program loop I have a gosub to a subroutine that writes to the chip

Code:
pcaChannel = 0                                            
i2cControl = $6 + 4*pcaChannel                            
I2CWRITE SDApin,SCLpin,i2cWriteAddress,i2cControl,[0,0,CH1_PWM.lowbyte,CH1_PWM.highbyte]

Now typically once the brightness (fadeset1, fadeset2, etc) has been set, and the condition is met to output the PWM value there would be no need to alter it whilst it's ON/OFF condition is met, and as the PCA chip maintains the value it only needs to be written to once at the start of the condition. However there is a need for the program to loop, and thus check for any of the on/off times are met and if so write the value of its corresponding fadeset variable, so how best to prevent the loop from writing to the PCA chip on each cycle.

Any ideas ?