If you're looking for the exact pinmapping for D10-D77 and D4-D87, go to the very bottom to skip the storytelling and jump straight to the answer. If you choose to read through, you will hear screams and see the hairs that have been ripped from my head...
Im currently in the process of making an ATSAM3X8E devboard based on Due. As the first step, i have working through Arduino schematics, CAD files, pinout diagram and datasheets. And, as with pretty much everyone who has walked this path already, i have come to the nightmare that is D10-D77 and D4-D87. To summarize;
D10 pin is connected to two physical pins on the SAM3X8E MCU; PC29(102) and PA28(111)
D4 pin is also connected to two physical pins on the SAM3X8E MCU; PC26(137) and PA29(112)
Note, when i say connected, those two pin pairs are shorted together, which can be verified by checking Eagle .pcb file accessible on Arduino Due web page.
The reason seems simple enough; PC29 is PWM and PA28 is SPI_CS, and the two functionalities need to be combined to maintain compatability with existing shields. In a similar way, PC26 is PWM and PA29 is SPI_CS, and function combining is again needed to maintain compatability with shields.
All is fine, until we come up to D77 written next to D10 and D87 written next to D4 on the pinout diagram. Meaning, it's theoretically possible to individually control two physical pins that are shorted together. Well, unless there are failsafes preventing dangerous pin combinations, (such as D10=HIGH, D77=LOW which would short the pins) it's best to forget D77 and D87 exists.
However, since im making my own board, which should be compatible with existing pin tags. But, on my board no pin pairing is done, so i needed to know which pins are D4, D10, D77 and D87, so i can label them correctly. Forums didn't provide an answer, (or likely i failed to find the answer within a few hours) subreddit didn't, neither Google. So, i finally manned up and looked up variant.h and variant.cpp files. On variant.h;
#define PIN_SPI_SS0 (77u)
#define PIN_SPI_SS1 (87u)
#define BOARD_SPI_SS0 (10u)
#define BOARD_SPI_SS1 (4u)
Umm, what? Where's the mention of PWM functionality? What does PIN_SPI and BOARD_SPI mean? Lemme look at variant.cpp;
* 4 NPCS1 | PA29 |
* TIOB6 | PC26 |
* 10 NPCS0 | PA28 |
* TIOB7 | PC29 |
So, both ports are mapped to D4 and D10 definitions? Therefore they will override D77 and D87 definitions? But then, why D77 and D87? Let's continue through;
* 77 NPCS0 | PA28 |
* 78 NPCS3 | PB23 | unconnected!
*
* USB pin | PORT
* ----------------+--------
* ID | PB11
* VBOF | PB10
*
*/
WTF? Where is D87? At least now we see D77 is SPI_CS, and that hints D87 is gotta be the other SPI_CS. Also, D4-PWM4 and D10-PWM10 seems like logical matches and writing analogWrite(87,XXX) to control PWM on D4 doesn't make much sense. But we still don't have a definitive answer, especially considering we have been reading through the comment lines. Let's read further down;
// 2
{ PIOB, PIO_PB25B_TIOA0, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC0_CHA0 }, // TIOA0
{ PIOC, PIO_PC28B_TIOA7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHA7 }, // TIOA7
{ PIOC, PIO_PC26B_TIOB6, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHB6 }, // TIOB6
// 10
{ PIOC, PIO_PC29B_TIOB7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHB7 }, // TIOB7
{ PIOD, PIO_PD7B_TIOA8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHA8 }, // TIOA8
{ PIOD, PIO_PD8B_TIOB8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHB8 }, // TIOB8
// 77 - SPI CS0
{ PIOA, PIO_PA28A_SPI0_NPCS0,ID_PIOA,PIO_PERIPH_A,PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS0
// 87 - SPI CS1
{ PIOA, PIO_PA29A_SPI0_NPCS1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS1
FINALLY! THE ANSWER! YAY!
D4: PC26, pin 137, PWM4
D10: PC29, pin 102, PWM10
D77: PA28, pin 111, SPI_CS0 (ETH_CS, default for ETH)
D87: PA29, pin 112, SPI_CS1 (SD_CS, default for SD card)
Oh my goodness, this shouldn't have been so painful. Should have checked the files first, could have saved so much trouble...
Ty the way, the files are located at C:\Users(YourUserName)\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\variants\arduino_due_x
Alright, now i can keep screaming and ripping my hair, for DIFFERENT reasons, hehe. Peace out!