Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Netduino Go Socket Pins as GPIO


  • Please log in to reply
4 replies to this topic

#1 Christopher Clark

Christopher Clark

    Member

  • Members
  • PipPip
  • 18 posts
  • LocationNorth Carolina, USA

Posted 14 September 2012 - 12:34 PM

Newbie Question

So I purchased a LED7R from GHI to try with my NetDuino Go, and I have had some success, but some issues.

I found this other post on the forums for using Netduino Go socket pins for IO pins, which is what I think I need to do. But I don't understand the answer given.

Regarding references to pins...if you take a look at the Netduino Go schematic, you can see which MCU pins go to which socket pins. PA0-PA15 can be referenced as (Cpu.Pin)0x00 through (Cpu.Pin)0x0F. PB0-PB15 can be referenced as (Cpu.Pin)0x10 through (Cpu.Pin)0x1F, and the pattern continues through the PC## pins, PD## pins, etc. (i.e. each port letter takes up 16 pin #s and they're all sequential).


If I read this correctly, I should be able to access all pins on the sockets. But I can't figure out the pin numbers, using the hex values doesn't compute to what I see working below.

I am using my LED7R on Netduino Go Socket 4.

I am able to turn on and off a couple of the LEDs, but I cannot figure out the other pins for the socket.

Based on the code in GoHub.cs method GetSocketPhysicalResources

case 4: // socket 4
gpio = (Cpu.Pin)0x23; //Pins.GPIO_PIN_C_3;
spi_mod = SPI.SPI_module.SPI1;
spi_cs = (Cpu.Pin)0x08; //Pins.GPIO_PIN_A_8;
led = (Cpu.Pin)0x19; //Pins.GPIO_PIN_B_9;

gpio (Cpu.Pin)0x23 maps to pin 3 so I am able to turn on D1 on the LED7R
spi_cs (Cpu.Pin)0x08 maps to pin 6 so I am able to turn on D4 on the LED7R

My first question, is that I can't understand the NetDuino Go Schematic pins. If I look at the schematic, I see that socket 4, pin 3, is GPIO_SOCKET4. Looking at the chip in the middle, GPI_SOCKET4 goes to PC3 pin 11. Well that is obviously not correct, as I am able to use (Cpu.Pin) 0x23 for GPIO on socket 4, and 0x23 is not 11. Can someone help me to understand how to read the pins from the schematic?

My question is, how do I directly address the other pins on socket 4?

Socket 4
Pin 3 GPIO_SOCKET4 which is (Cpu.Pin) 0x23
Pin 4 USART2_TX which is ???
Pin 5 USART2_RX which is ???
Pin 6 SPI_CS_SOCKET4 which is (Cpu.Pin) 0x08
Pin 7 SPI1_MOSI which is ???
Pin 8 SPI1_MISO which is ???
Pin 9 SPI1_SCK which is ???

#2 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 14 September 2012 - 01:00 PM

Looking at the chip in the middle, GPI_SOCKET4 goes to PC3 pin 11. Well that is obviously not correct, as I am able to use (Cpu.Pin) 0x23 for GPIO on socket 4, and 0x23 is not 11.

You are mixing logical GPIO port pin numbers represented by the Pins enumeration and physical package pin numbers, which are completely independent (and in fact vary for different packages). Pins number is sequential for GPIO ports, so for port PA the first pin PA0 = 0, PA1 = 1, ... PA15 = 15, then PB0 = 16, PB1 = 17, ..., PB15 = 31, PC0 = 32, PC1 = 33, PC2 = 34, PC3 = 35 = 0x23.

Pin 3 GPIO_SOCKET4 which is (Cpu.Pin) 0x23
Pin 4 USART2_TX which is PA2 = (Cpu.Pin)2
Pin 5 USART2_RX which is PA3 = (Cpu.Pin)3
Pin 6 SPI_CS_SOCKET4 which is (Cpu.Pin) 0x08
Pin 7 SPI1_MOSI which is PA7 = (Cpu.Pin)7
Pin 8 SPI1_MISO which is PA6 = (Cpu.Pin)6
Pin 9 SPI1_SCK which is PA5 = (Cpu.Pin)5

#3 Christopher Clark

Christopher Clark

    Member

  • Members
  • PipPip
  • 18 posts
  • LocationNorth Carolina, USA

Posted 14 September 2012 - 02:27 PM

Thank you. Your information allowed me to get the GHI Electronics LEDR7 working on Netduino Go Socket 4.
A few more questions if you could.

These pins worked for Socket 4.

Pin 3 GPIO_SOCKET4 which is (Cpu.Pin) 0x23
Pin 4 USART2_TX which is PA2 = (Cpu.Pin)2
Pin 5 USART2_RX which is PA3 = (Cpu.Pin)3
Pin 6 SPI_CS_SOCKET4 which is (Cpu.Pin) 0x08
Pin 7 SPI1_MOSI which is PA7 = (Cpu.Pin)7
Pin 8 SPI1_MISO which is PA6 = (Cpu.Pin)6
Pin 9 SPI1_SCK which is PA5 = (Cpu.Pin)5


When I look at the Netduino Go Schematic for Socket 3, pins 4,5,7,8,9 have the same names as socket 4.

When I compare this to the GoHub.cs file:
  • The same pins are used for SPI.SPI_module.SPI1 in the sockets 1-4.
  • The same pins are used for SPI.SPI_module.SPI2 in the sockets 5-8.

Only the names for Pins 3 and 6 change.

Based on this GoHub.cs code within GetSocketPhysicalResources
case 3: // Socket 3
gpio = (Cpu.Pin)0x22; //Pins.GPIO_PIN_C_2;
spi_mod = SPI.SPI_module.SPI1;
spi_cs = (Cpu.Pin)0x04; //Pins.GPIO_PIN_A_4;
led = (Cpu.Pin)0x18; //Pins.GPIO_PIN_B_8;
break;

Would this be the correct pins for Socket 3?

Pin 3 GPIO_SOCKET3 which is (Cpu.Pin) 0x22
Pin 4 USART2_TX which is PA2 = (Cpu.Pin)2
Pin 5 USART2_RX which is PA3 = (Cpu.Pin)3
Pin 6 SPI_CS_SOCKET3 which is (Cpu.Pin) 0x04
Pin 7 SPI1_MOSI which is PA7 = (Cpu.Pin)7
Pin 8 SPI1_MISO which is PA6 = (Cpu.Pin)6
Pin 9 SPI1_SCK which is PA5 = (Cpu.Pin)5

Will I get into trouble using multiple of these LEDR7 modules within the sockets 1-4, and sockets 5-8?

You are mixing logical GPIO port pin numbers represented by the Pins enumeration and physical package pin numbers, which are completely independent (and in fact vary for different packages). Pins number is sequential for GPIO ports, so for port PA the first pin PA0 = 0, PA1 = 1, ... PA15 = 15, then PB0 = 16, PB1 = 17, ..., PB15 = 31, PC0 = 32, PC1 = 33, PC2 = 34, PC3 = 35 = 0x23.


When I read this, I think that PA0-15 = Socket 1, PB0-15 = Socket 2, PC0-15 = Socket 3, PD0-15 = Socket 4, etc...
I don't think this correct? Could you explain what I am missing here?

#4 ErikN

ErikN

    Advanced Member

  • Members
  • PipPipPip
  • 119 posts
  • LocationNew York, NY

Posted 14 September 2012 - 04:22 PM

When I compare this to the GoHub.cs file:<br style="color: rgb(28, 40, 55); font-size: 13px; line-height: 19px; background-color: rgb(250, 251, 252); ">

  • The same pins are used for SPI.SPI_module.SPI1 in the sockets 1-4.
  • The same pins are used for SPI.SPI_module.SPI2 in the sockets 5-8.


That's the bus part of GoBus and why, in the early days of Go if you use the Shield Base, you can't use the other ports in that bus. 1-4 share a bus and 5-8 share a bus. (With the new updates, this won't be a problem with the Shield Base but this is to demonstrate the shared nature of the bus. This is still a limitation if you use some Gadgeteer modules on the Go board. There are some discussions in the forums about this.)

The pins that are different are chip select to let the device on a bus know whether or not it is the device being communicated with.

#5 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 14 September 2012 - 06:12 PM

When I read this, I think that PA0-15 = Socket 1, PB0-15 = Socket 2, PC0-15 = Socket 3, PD0-15 = Socket 4, etc...
I don't think this correct? Could you explain what I am missing here?

Nope, it is not correct. The key here is that the sockets communicate over the SPI bus, they do not expose individual GPIO pins. As you've already mentioned above, sockets 1-4 are on SPI1 bus, sockets 5.-8 are on SPI2 bus. SPI allows multiple slaves to share the same connection and they are controlled by so called 'slave select' (or 'chip select') pin. In order to have N devices on an SPI bus, you need only 3 SPI data lines (clock, MISO, MOSI) plus N signals to enable a particular slave - these are /SPI_CS_SOCKETx signals.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.