Author Topic: Simblee - optimal GPIO pin selection  (Read 1629 times)

Tim

  • RFduino Sr. Member
  • ****
  • Posts: 119
  • Karma: +2/-0
    • View Profile
Simblee - optimal GPIO pin selection
« on: May 25, 2016, 09:50:00 PM »
Hello ...

Our product will use Simblee and requires the following IO:

Analog input 1: connected to a phototransistor to read analog light value
Digital input 1: connected to comparator that changes phototransistor analog value to digital 0/1
Digital 2/3: connected to SDA/SCL pins of Maxim’s DS3231 (so DS3231 can be programmed via I2C)
Digital in 4: connected to SQW pin of Maxim’s DS3231 (which, in turn, increments TIMER1 as counter to count seconds)

GPIO 0 and 1 are reserved for programming Simblee (UART).

For SCL/SDA, best to use default GPIO pins 5 and 6?

For phototransistor analog input pin, use any of GPIO 2, 3 or 4?

For digital input pins for comparator output and DS3132 SQW output, use first digital in/out-only pins, GPIO 7 and 8?

Any advantage of using non-adjacent pins? Any other considerations?

Many thanks,

Tim

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Simblee - optimal GPIO pin selection
« Reply #1 on: May 27, 2016, 09:46:24 AM »
Hi Tim,

Your layout plan seems reasonable. I haven't heard of any issues with pin utilization. We have no idea how the pins are actually routed within the modules so just have to trust they are layed out well. The nRF5 pins are redefinable to make your board layout design easier. Well, except for the analog ones are fixed. And your right about wanting to keep GPIO[0-1] reserverd for programming.




Tim

  • RFduino Sr. Member
  • ****
  • Posts: 119
  • Karma: +2/-0
    • View Profile
Re: Simblee - optimal GPIO pin selection
« Reply #2 on: May 29, 2016, 09:13:24 PM »
Thanks Tolson. It's always comforting and reassuring to hear your opinion about things.

This m

Tim

  • RFduino Sr. Member
  • ****
  • Posts: 119
  • Karma: +2/-0
    • View Profile
Re: Simblee - optimal GPIO pin selection
« Reply #3 on: June 03, 2016, 07:49:59 AM »
Tolson, could you say a bit more about redefining pins? Assuming Vcc, ground, reset and others (analog pins, as you say?) cannot be redefined. Is it simply that all digital GPIO pins can be redefined?

Is it true that SDA and SCL (I2C) carry digital signals and, therefore, can be configured to use any of the GPIO pins? It would be helpful for my board design to move them to the Vcc edge of Simblee.

Many thanks,

Tim

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Simblee - optimal GPIO pin selection
« Reply #4 on: June 03, 2016, 02:19:42 PM »

Wire.beginOnPins(SCLpin,SDApin);

Where any available GPIO pin can be used.

Tim

  • RFduino Sr. Member
  • ****
  • Posts: 119
  • Karma: +2/-0
    • View Profile
Re: Simblee - optimal GPIO pin selection
« Reply #5 on: June 06, 2016, 07:42:44 AM »
Could you say a bit about redefining pins? I'm assuming that that means have a particular pin function (e.g. GPIO 20) show up at a different physical pin on Simblee. How is a pin redefined? And which pins can be redefined? I'm assuming that pins like VDD, GND, and RESET cannot be redefined.

Thanks,

Tim

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Simblee - optimal GPIO pin selection
« Reply #6 on: June 06, 2016, 08:30:54 AM »
Just the pins that are GPIO pins.
So if you want I2C SCL on 10 and SDA on pin 20 then Wire.beginOnPins(10,20).
To change what pins you want SPI on you have to modify the variants.h file

Of interest is the nRF chip version used in the Simblee can run 2 I2C and 2 SPI and SPI slave modes, but so far there really isn't any support for all that in the Simblee API. I think. So to use those will require you to do the low level Nordic calls again.



Tim

  • RFduino Sr. Member
  • ****
  • Posts: 119
  • Karma: +2/-0
    • View Profile
Re: Simblee - optimal GPIO pin selection
« Reply #7 on: June 06, 2016, 09:21:17 PM »
Thanks Tolson. This confirms my understanding.

Tim

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Simblee - optimal GPIO pin selection
« Reply #8 on: June 14, 2016, 01:34:41 PM »
Hi Tim,

You can also use both separate I2C busses that are available on Simblee.
Example dual bus scanner
i2c_scanner_dual.ino
Code: [Select]
// --------------------------------------
// i2c_scanner_dual
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//
// Version ThomasOlson teo20140527.01 works with RFduino with mods.
//
// Version ThomasOlson teo20160612.01 Modified to test both I2C
// busses on 3rd generation nRF51822 as in Simblee

#include <Wire.h>


void setup()
{

  Serial.begin(9600);
  Serial.println("\nI2C Scanner");

  Wire.begin(); // default SCL = 5, SDA = 6
  //Wire.beginOnPins(5,6);
  //Wire2.begin(); // default SCL2 = 13, SDA = 14
  Wire2.beginOnPins(2,3);
 
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning Bus 1 ...");

  nDevices = 0;

  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    Wire.write(0x00);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device on bus 1 found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }else{
//      Serial.print("Error ");
//      Serial.print(error);
//      Serial.print(" at address 0x");
//      if (address<16)
//        Serial.print("0");
//      Serial.println(address,HEX);
    }   
  }
 
  if (nDevices == 0){
    Serial.println("No I2C devices found on bus 1\n");
  }else{
    Serial.print(nDevices);
    Serial.println(" found\n");
  }



  Serial.println("Scanning Bus 2 ...");

  nDevices = 0;

  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire2.beginTransmission(address);
    Wire2.write(0x00);
    error = Wire2.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C bus 2 device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }else{
//      Serial.print("Error ");
//      Serial.print(error);
//      Serial.print(" at address 0x");
//      if (address<16)
//        Serial.print("0");
//      Serial.println(address,HEX);
    }   
  }
 
  if (nDevices == 0){
    Serial.println("No I2C devices found on bus 2\n");
  }else{
    Serial.print(nDevices);
    Serial.println(" found\n");
  }

  delay(5000);           // wait 5 seconds for next scan
}


Results on my two busses...
Quote
I2C Scanner
Scanning Bus 1 ...
I2C device on bus 1 found at address 0x57   !
I2C device on bus 1 found at address 0x68   !
2 found

Scanning Bus 2 ...
I2C bus 2 device found at address 0x48   !
1 found

RFdigital hasn't updated any API documentation in yarns. But this is best guess what it should be! Seems to work.

« Last Edit: June 14, 2016, 01:43:18 PM by tolson »

LulaNord

  • RFduino Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Simblee - optimal GPIO pin selection
« Reply #9 on: April 18, 2017, 09:00:59 AM »
Hi...as per my knowledge any issues with pin utilization. We have no idea how the pins are actually routed within the modules so just have to trust they are layed out well. The nRF5 pins are redefinable to make your board layout design easier. Well, except for the analog ones are fixed. And your right about wanting to keep GPIO[0-1] reserverd for programming.

circuit board assembly
« Last Edit: June 01, 2017, 08:44:15 AM by LulaNord »