How can I recover the the contents of the Capture registers after ERT_A/B have been written over by programming a match?

eTPU_C

Invoke:

chan = chan;

The compiler will not optimize this out, as there are side effects.

Recovering the Capture register values

When a thread starts, ERT_A/B are loaded with the values of the Capture registers. This code reloads those values after using ERT_A/B for other purposes.

                                          /* Thread starts, ERT_A/B = Capture */

                                          erta = 0x555;
0200 015F253D   alu erta = #0x0555.
0204                                      ertb = 0xAAA;

0204 02AF36D9   alu ertb = #0x0AAA.
0208                                      channel.ERWA = 0b0;
                                          channel.ERWB = 0b0;

0208 7FF94F43   alu chan = chan ,ccs;     chan = chan;
                    chan write_erta,
                    write_ertb.