I think I found the solution to my problem on the reference manual. I just had to enable the "Output compare preload" option on both channels I am using.
I implemented your solution and it works for a fixed phase shift, independently of its value. The begins when I change the phase shift over time. Frequently the phase swithces from the value I want to its exact complement (if X is the shift I want, 1...