NeoSWSerial error on Pro Micro

This question is primarily for slash dev, since I know he wrote the code, but I thought I would post it in case anyone else has a similar issue.

I'm trying to rework code from an Uno to a SparkFun Pro Micro. The first step is to rx/tx gps data over serial ports 8 and 9. I chose NeoSWSerial over AltSoftSerial because AltSoftSerial on a micro seems to require ports 5 and 13, and 13 is not available. (If there is an easy way to use AltSoftSerial on 8,9 on a micro that would work fine for me). 8 and 9 seem to be the only ports I can use because other available ports will be used for logging to SD.

In using NewSWSerial, I get the following error when uploading:

Arduino: 1.8.5 (Windows 10), Board: "SparkFun Pro Micro, ATmega32U4 (5V, 16 MHz)"

--snip--

C:\Users\gka\OneDrive\Documents\Arduino\libraries\NeoSWSerial\src\NeoSWSerial.cpp: In member function 'void NeoSWSerial::listen()':

C:\Users\gka\OneDrive\Documents\Arduino\libraries\NeoSWSerial\src\NeoSWSerial.cpp:155:7: error: 'TCCR2A' was not declared in this scope

       TCCR2A = 0x00;

       ^

C:\Users\gka\OneDrive\Documents\Arduino\libraries\NeoSWSerial\src\NeoSWSerial.cpp:156:7: error: 'TCCR2B' was not declared in this scope

       TCCR2B = 0x03;  // divide by 32

       ^

Using library NeoSWSerial at version 3.0.5 in folder: C:\Users\gka\OneDrive\Documents\Arduino\libraries\NeoSWSerial 
Using library NeoGPS at version 4.2.3 in folder: C:\Users\gka\OneDrive\Documents\Arduino\libraries\NeoGPS 
exit status 1
Error compiling for board SparkFun Pro Micro.

The actual code is:

#include <NeoSWSerial.h>
NeoSWSerial gpsPort(8, 9);

#include <NMEAGPS.h>
NMEAGPS gps;

void setup() {

  // connect at 115200 so we can read the GPS fast enough and echo without dropping chars
  // also spit it out
  Serial.begin(115200);

  gpsPort.begin( 9600 );

  gps.send_P( &gpsPort, F("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") ); // RMC_GGA
  delay( 100 );
  gps.send_P( &gpsPort, F("PMTK220,200") );  // 5Hz
  delay( 100 );
  gps.send_P( &gpsPort, F("PGCMD,33,0") );   // No antenna status messages needed
  delay( 100 );

  delay( 5000 );

  Serial.println("Ready!");
}


void loop() {
  if (gpsPort.available())
    Serial.write( gpsPort.read() );
}

I saw on your GitHub page that this is a known error, so please disregard unless there has been a solution since that post.

disregard unless there has been a solution since that post.

There is a pull request that contains modified files for use on a 32U4. It has not been tested on other platforms, so I have been reluctant to fold it in. You could try it.

It uses TIMER4 instead of the millis TIMER0, so that's another reason I've been reluctant. So far, NeoSWSerial does not use any additional resources. If you are using TIMER4 for something else, this won't work for you.

Cheers,
/dev

In case someone else has a similar problem, I ended up getting AltSoftSerial to work by modifying the AltSoftSerial_Board.h file to comment out 13 RX,5 TX on Timer3 and instead using 4 RX, 9 TX on Timer1.

I got the idea from Using AltSoftSerial with Pro Micro / Leonardo Mini Micro Clones w/ATmega32U4 MU - Programming Questions - Arduino Forum but did it slightly differently (the first poster used 4 RX on Timer1 but kept 5 TX on Timer3).