Hi Marco,
Thanks for sharing the waveform. I don’t think this scenario can be achieved using Blackfin GPIOs and Timers.
In your case, since you are using GP interrupt on rising edge of ‘ref wave’, there will be latency between the rising edge and start of Timer3. This is because of interrupt latency and Timer MMRs write latency. Hence the start of ‘ref wave’ and ‘pwm (timer3)’ cannot be synchronized.
Since you also mentioned that the ‘ref wave’ can have a variable frequency, it is not possible to program the width and period of Timer3 before half-period of ‘ref wave’ is complete. You should first measure the width of ‘ref wave’ (through Timer width capture mode), program the Timer3 Period and Width register accordingly and start Timer3. Note that here also you will see a latency because you have to wait for an interrupt of Timer Width capture complete and then write to Timer MMRs.
Best Regards,
Suraj.