The challenge that I am trying to solve, is to keep A and B running accurately, while I am running a loop in software.
The T4 has 2 x GPT (general purpose timer), which are 32-bit, which will simplify your application a lot, I think. Each GPT has 3 x output compare registers, so I think what you would need to do is select 2 pins that can be assigned to 2 of the output compare functions of either GPT1 or GPT2. Both pins should be on the same GPT.
I think the GPT can be configured to use either the 24 MHz or 150 MHz clock. Either one is okay in your case because either would support 1 us pulses and long periods (seconds) between pulses. Generating a B or C pulse could be done something like this:
- start with the output low and set for toggle on match
- read the value of the timer
- set the output compare to generate the rising edge
- enable the match interrupt
- on the rising edge interrupt, set the output compare for the falling edge
- on the falling edge interrupt, set the output compare for the next rising edge
If you think of this is as describing the B pulse, the C pulse would be done the same way, with the rising edge of C set to 0.5 us sooner than the rising edge of B. Because both B and C are running on the same timer, it's easy to compute the value of the timer for:
- rising and falling edge of C
- rising and falling edge of B
All 3 output compare functions share one interrupt, so the ISR has to check flags to see which match has occurred and what to do next. It will be tricky to set up, but it will take almost no CPU time, so it won't get in the way of whatever else needs to be done.