Using all 9 timers with external triggers for interval measurement

For a project, we need to measure 9 independent external signals (interval between rising / falling edges). This works perfectly well for 6 timers in TC0 and TC2 using this mapping to the I/O pins:

ISR/IRQ/TC/Channel/Due pins
TC0 TC0 0 2, 13
TC1 TC0 1 60, 61
TC2 TC0 2 58
TC3 TC1 0 none
TC4 TC1 1 none
TC5 TC1 2 none
TC6 TC2 0 4, 5
TC7 TC2 1 3, 10
TC8 TC2 2 11, 12

My question is if by switching to peripheral B, is it possible to also trigger the three timers of TC1 (marked "none" in the table above) by an external signal? Has anybody done that yet? Is there some code around for the initial configuration of peripheral A & B for that case? Thanks for any advice in advance.

When you use TC_CMR in capture mode, you select TIOA or TIOB as the external trigger. Therefore, obviously, you need the TIOAx or TIOBx pins to be broken out. See page 858 for TIOAx/TIOBx pins and compare with the Greynomad pinout diagram ( TIOA3,4,5 and TIOB3,4,5 are not broken out).

If the time intervals you are measuring are not too short, attachinterrupt() works too with the CHANGE parameter.

Thanks for your fast response. Unfortunately, we can't use normal interrupts because we really need the capture mode and the high resolution of the timers (the intervals we measure are considerably shorter than 1us).

Just looking one page further in the Atmel datasheet (page 859), there I see that TIOB3,4,5 can be mapped to PB1,3,5 by using peripheral B instead of A. At least, that's my understanding of that table. Hence the question if that is indeed the case and if someone already is using that. Any clarification regarding peripheral A vs. B is welcome.

schubige:
I see that TIOB3,4,5 can be mapped to PB1,3,5 by using peripheral B instead of A.

And where do you imagine these pins are broken out when you look at the pinout diagram ?

If attachinterrupt can't work because too slow, you can still read an input pin with PIO_PDSR and compare with the previous reading in loop(), this is super fast.

If you are stuck with input capture, I see 2 workarounds:
Use 2 arduino DUE boards and connect them via Serial1, or use a DUE compatible board with all pins broken out such as the Taijuino board
https://www.emartee.com/product/42271/Taijiuino%20Due%20Pro%20R3%20%20Arduino%20Due%20Compatible

And where do you imagine these pins are broken out when you look at the pinout diagram ?

Well, they should be available at the chip (pins 114, 118, 120 - usually used for the ethernet interface). I don't mind soldering these three wires if I'm sure that the chip can be configured in a way so I can use all 9 timers. But probably a different board is the easier way to go. Nevertheless, it would be great to have an answer regarding peripheral A vs. B just to be sure that I understand the data sheet correctly.

schubige:
it would be great to have an answer regarding peripheral A vs. B just to be sure that I understand the data sheet correctly.

You have to follow pages 858/859 to select from peripheral type A or B.

schubige:
Well, they should be available at the chip (pins 114, 118, 120 - usually used for the ethernet interface). I don't mind soldering these three wires if I'm sure that the chip can be configured in a way so I can use all 9 timers.

Super !

Sam3x datasheet, page 881:
ABETRG bit in TC_CMR register
• ABETRG: TIOA or TIOB External Trigger Selection
0: TIOB is used as an external trigger.
1: TIOA is used as an external trigger.

Sam3x datsheet, page 858/859:
e.g. TIOA4 , I/O line PIOB2 peripheral B
PMC->PMC_PCER0 |= PMC_PCER0_PID31; // TC4 power ON
PIOB->PIO_PDR |= PIO_PDR_P2; // the pin is no more driven by the GPIO but TC4
PIOB->PIO_ABSR |= PIO_PB2B_TIOA4; // Select Peripheral type B

Great. I will give it a try. Thanks a lot!