SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By Scott216
#178379
I believe that only certain pins can be used for Rx when using SoftwareSerial library. Which pins on the Pro-Mini support SoftwareSerial Rx?
By Mee_n_Mac
#178383
The SoftSerial page doesn't mention any restrictions for a 328 based boards and the Pro-Mini uses a 328 MCU. The page does mention that it uses pin change interrupts and that's why there are restrictions on which pins can be used on other Arduinos. From what I can tell from the 328 datasheet, all pins are capable of being setup for a pin change interrupt.

http://arduino.cc/en/Reference/SoftwareSerial
Limitations
The library has the following known limitations:
- If using multiple software serial ports, only one can receive data at a time.
- Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).
- Not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

If your project requires simultaneous data flows, see Paul Stoffregen's AltSoftSerial library. AltSoftSerial overcomes a number of other issues with the core SoftwareSerial, but has it's own limitations. Refer to the AltSoftSerial site for more information.


From the 328 datasheet ...
The pin change interrupt PCI2 will trigger if any enabled PCINT23..16 pin toggles. The pin change
interrupt PCI1 will trigger if any enabled PCINT14..8 pin toggles. The pin change interrupt PCI0
will trigger if any enabled PCINT7..0 pin toggles. The PCMSK2, PCMSK1 and PCMSK0 Registers
control which pins contribute to the pin change interrupts. Pin change interrupts on
PCINT23..0 are detected asynchronously. This implies that these interrupts can be used for
waking the part also from sleep modes other than Idle mode.
By Scott216
#178386
I've got my pro-mini hooked up to a MAX485 chip so it's reading RS-485 data. SoftwareSerial works when D13 is Rx and D12 is Tx. But if I swap them it doesn't work. I do swap them physically and in my code. I also tried moving Rx to pins D6 - D11, leaving Tx on D12 and it doesn't work on any of those pins.
By Mee_n_Mac
#178387
D11 is the MOSI pin, Port B pin 3. D12 is the MISO pin, Port B pin 4. D13 is the SCLK pin, Port B pin 5. Those are PCINT3-5 which should, if configured properly, trigger PCI0. So I have to guess that the SoftSerial library isn't configuring that interrupt correctly or there's something in your code that's competing for use of those pins ??? You're not including the SPI library or trying to do anything "SPI-ish" are you ? :?

D8-10 are on Port B as well and so are served by PCI0 as well. :?:

D6, D7 are Port D, as are D4 and D5, so that's a different PCIx pin change interrupt. It's odd that D4 and D5 would work if D6 and D7 don't. :shock:

Other than that I don't know. Have you searched for any SoftSerial problems related to D11 or D12 or D13 or ??
By Scott216
#178388
No SPI. I am writing to the serial monitor. Here's my sketch:
Code: Select all
#define LINE_START 0

#include <Arduino.h>
#include <SoftwareSerial.h>  // http://arduino.cc/en/Reference/softwareSerial

const byte RS485_A_PIN =           13;  // Rx Pin
const byte RS485_B_PIN =           12;  // Tx Pin
SoftwareSerial windTracker(RS485_A_PIN, RS485_B_PIN);  // (Rx, Tx) 

void setup() 
{
  windTracker.begin(9600);     // opens serial port, sets data rate to 9600 bps
  Serial.begin(9600);
  delay(4000);

  Serial.println("RS-485 test");
  delay(500);
}

void loop()
{
  readData();
}


void readData()
{
  char windSpeed[5];
  char windDirection[4];
  byte b;
  if (windTracker.available() > 25) 
  { 
     
    b = windTracker.read();
    if ( b == LINE_START) 
    {
      for (byte s = 0; s < 4; s++)
      { windSpeed[s] = windTracker.read(); }
      windSpeed[4] = '\0';
      
      windTracker.read(); // read the space character
      
      for (byte d = 0; d < 3; d++)
      { windDirection[d] = windTracker.read(); }
      windDirection[3] = '\0';
      
      float windSpeedKnots = atof(windSpeed) * 1.94384;
      int iWindDirection = atoi(windDirection);
      Serial.print(windSpeedKnots);
      Serial.print("\t");
      Serial.println(iWindDirection);
    }
  }
}