Have you thought of using a Flag variable?
During your checking routine, set a Flag if you need to write to the PCA.
Check the Flag to determine if you need to do the gosub to write to the PCA chip.