Question about 120E pin P2.31 (SD card SD/MMC)

I’m sure a simple answer to this but I do not understand.

Using a G120E Dev board 1.2
Question about 120E pin P2.31 (SD card SD/MMC)

P2.31/SD.CD
G120E CPU Pin 56 - IO33/P0.6 - P2.31/SD.CD

Cpu.Pin portId (uint data1) received is 63.

How does 63 relate to the actual Cpu Pin which is 56?

// The following event does work as intended
// Code is only to test the events for now.

private static void Program_OnInterrupt_sdCardInsert(uint data1, uint data2, DateTime time)
{
	Debug.Print("Data1 (Cpu.Pin portId) " + data1.ToString() + " Data2 " + data2.ToString());
	
	// >> Cpu.Pin portId (uint data1) received is 63 <<
	
	if (data2 == 0) //Edge goes low on card inserted
	{
		Debug.Print("SD Card inserted!");
	}
	else //When edge returns high on card removed
	{
		Debug.Print("SD Card removed!");
	}
}
//

Partial code used

// SDCARD <<<
//InterruptPort(Cpu.Pin portId, bool glitchFilter, Port.ResistorMode resistor, Port.InterruptMode interrupt);

interrupt_ports = new InterruptPort[]
{		
new InterruptPort(sdCard.SD_CD, true, Port.ResistorMode.Disabled,  Port.InterruptMode.InterruptEdgeBoth),
};
//Array of interrupt ports
// SDCARD <<<
interrupt_ports[5].OnInterrupt += Program_OnInterrupt_sdCardInsert;

static class sdCard
{
	public const Cpu.Pin SD_D0 = G120E.Gpio.P1_6;
	public const Cpu.Pin SD_D1 = G120E.Gpio.P1_7;
	public const Cpu.Pin SD_D2 = G120E.Gpio.P1_11;
	public const Cpu.Pin SD_D3 = G120E.Gpio.P1_12;
	public const Cpu.Pin SD_CLK = G120E.Gpio.P1_2;
	public const Cpu.Pin SD_CMD = G120E.Gpio.P1_3;
	//Interrupt event
	public const Cpu.Pin SD_CD = G120E.Gpio.P2_31;  // <<<
}
//

Thanks and Happy Thanksgiving to ALL

There are two numbering systems. One is dependent on the package of the device. For example 48 pin version of the chip vs 64 pin package of the same microcontroller. The second is the one that is used in the code and is package independent.

I think a quick look at the pinout table in the datasheet will clear things up.

@ Gus -

G120 and G120E SoM Datasheet Rev 1.0

4.2 G120E Pinout Page 8
I assume in the following this is Pin 63 and 56:
63  P1.11 SD D2
56  P2.31 (No info)

No need to continue. I only thought there may be a simple answer.

@ Architect -

Thanks…
I’ll have to think on this a bit… Not sure I understand.

I was reading this.

portIdType: Microsoft.SPOT.Hardware…::…Cpu…::…Pin
The identifier for the interrupt port. If the port with the specified identifier is already in use, an exception is thrown.

‘The identifier’ … From this maybe it has nothing to do with a particular CPU Pin but rather something that is a internal identifier the interpreter generates?

Just a thought…

For example, pin 1 maybe the power pin and pin 32 is the ground pin…reset is pin 1234. And so out happens that pin maybe P1.43. The internal “pin function” has nothing to do with the physical “pin number”.

G400 comes in two formats, with different pin count. But both have the same internal pin functions… Another example :slight_smile:

Also, you should not use the Microsoft pin identifiers. Use the ones we provide in the pins class. Those match our documentation.

@ Gus -

Thank you!

As a side note:

Old document I found by:

Pin identification numbers (IDs) are consecutive, where:
• GPIO Port A Pin 0-31 numbers are 0-31
• GPIO Port B Pin 0-31 numbers are 32-63
• GPIO Port C Pin 0-31 numbers are 64-95
and so on

I checked the returned Cpu.Pin portId value returned by the 5 button group on my board.
No value matches the actual CPU pin number.

Interrupt pins used
SD CD Cpu.Pin portId = 63 for P2.31 actual CPU Pin is 56
Up button Cpu.Pin portId = 42 for P2.10 actual CPU Pin is 53
Down button Cpu.Pin portId = 22 for P0.22 actual CPU Pin is 7
Left button Cpu.Pin portId = 53 for P2.21 actual CPU Pin is 20
Right button Cpu.Pin portId = 54 for P2.22 actual CPU Pin is 22
Select button Cpu.Pin portId = 57 for P2.25 actual CPU Pin is 21

I now understand…