I am unable to see a way to solve this problem and make it portable across patforms. The only solution I can see is adding a fixed cycle delay, which is really bad coding.
Can someone offer a 'nice' way to do this?
//Start output event in 0x0100 counts, this could be called at ANYTIME, so it has to happen before TMPxCnSC.
TPM1C3V = TPM1CNT + 0x0100;
//Worlds worst fix; eat a few bus cycles, this must be greater than the slowest TMP tick rate (will change with bus frequency change and prescale change so I cannot see a way to make this code nice and portable across processors with different prescale rates and different bus rates as this code's speed will change with bus, and the TPM will change depending on its setings. Its also bad as it holds up the processor in interrupt eating up valuable processor cycles.
for(i = 0;i != 5; ++i);
//Set output on compare
//Enable interrupt
//Clear previously set interrupt flag
TPM1C3SC = 0b01011000;
This is ugly, surely I have missed an obvious way to make this work 'nicely'