SlashDevin / NeoSWSerial

Efficient alternative to SoftwareSerial with attachInterrupt for RX chars, simultaneous RX & TX
173 stars 42 forks source link

Doesn't compile for ATMega1284P on Mightycore at 20Mhz #50

Open FRCIndustries opened 2 years ago

FRCIndustries commented 2 years ago

Attempting to compile NeoSWSerial on the 1284P, using Mightycore, with the specification for the 20Mhz crystal, results in the following compiler errors:

Compiling library "NeoSWSerial"
"C:\\Users\\chris\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -std=gnu++17 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega1284p -DF_CPU=20000000L -DARDUINO=10813 -DARDUINO_AVR_ATmega1284 -DARDUINO_ARCH_AVR "-IC:\\Users\\chris\\AppData\\Local\\Arduino15\\packages\\MightyCore\\hardware\\avr\\2.1.3\\cores\\MCUdude_corefiles" "-IC:\\Users\\chris\\AppData\\Local\\Arduino15\\packages\\MightyCore\\hardware\\avr\\2.1.3\\variants\\standard" "-ID:\\Documents\\Arduino\\libraries\\Adafruit_BME280_Library" "-ID:\\Documents\\Arduino\\libraries\\Adafruit_BusIO" "-IC:\\Users\\chris\\AppData\\Local\\Arduino15\\packages\\MightyCore\\hardware\\avr\\2.1.3\\libraries\\Wire\\src" "-IC:\\Users\\chris\\AppData\\Local\\Arduino15\\packages\\MightyCore\\hardware\\avr\\2.1.3\\libraries\\SPI\\src" "-ID:\\Documents\\Arduino\\libraries\\Adafruit_Unified_Sensor" "-ID:\\Documents\\Arduino\\libraries\\Adafruit_INA260_Library" "-ID:\\Documents\\Arduino\\libraries\\RTClib\\src" "-ID:\\Documents\\Arduino\\libraries\\NeoSWSerial\\src" "-IC:\\Users\\chris\\AppData\\Local\\Arduino15\\packages\\MightyCore\\hardware\\avr\\2.1.3\\libraries\\EEPROM\\src" "-ID:\\Documents\\Arduino\\libraries\\MemoryFree-master" "-IC:\\Program Files (x86)\\Arduino\\libraries\\ArduinoShrink\\src" "-ID:\\Documents\\Arduino\\libraries\\Adafruit_MCP23017_Arduino_Library\\src" "-ID:\\Documents\\Arduino\\libraries\\Adafruit_PCF8591" "D:\\Documents\\Arduino\\libraries\\NeoSWSerial\\src\\NeoSWSerial.cpp" -o "C:\\Users\\chris\\AppData\\Local\\Temp\\arduino_build_760383\\libraries\\NeoSWSerial\\NeoSWSerial.cpp.o"
D:\Documents\Arduino\libraries\NeoSWSerial\src\NeoSWSerial.cpp: In static member function 'static void NeoSWSerial::rxISR(uint8_t)':
D:\Documents\Arduino\libraries\NeoSWSerial\src\NeoSWSerial.cpp:308:16: error: 'TCNTX' was not declared in this scope
   uint8_t t0 = TCNTX;            // time of data transition (plus ISR latency)
                ^~~~~
D:\Documents\Arduino\libraries\NeoSWSerial\src\NeoSWSerial.cpp:308:16: note: suggested alternative: 'TCNT0'
   uint8_t t0 = TCNTX;            // time of data transition (plus ISR latency)
                ^~~~~
                TCNT0
D:\Documents\Arduino\libraries\NeoSWSerial\src\NeoSWSerial.cpp: In member function 'bool NeoSWSerial::checkRxTime()':
D:\Documents\Arduino\libraries\NeoSWSerial\src\NeoSWSerial.cpp:383:28: error: 'TCNTX' was not declared in this scope
       uint8_t  t0        = TCNTX; // now
                            ^~~~~
D:\Documents\Arduino\libraries\NeoSWSerial\src\NeoSWSerial.cpp:383:28: note: suggested alternative: 'TCNT0'
       uint8_t  t0        = TCNTX; // now
                            ^~~~~
                            TCNT0
D:\Documents\Arduino\libraries\NeoSWSerial\src\NeoSWSerial.cpp: In member function 'virtual size_t NeoSWSerial::write(uint8_t)':
D:\Documents\Arduino\libraries\NeoSWSerial\src\NeoSWSerial.cpp:536:18: error: 'TCNTX' was not declared in this scope
     uint8_t t0 = TCNTX; // start time
                  ^~~~~
D:\Documents\Arduino\libraries\NeoSWSerial\src\NeoSWSerial.cpp:536:18: note: suggested alternative: 'TCNT0'
     uint8_t t0 = TCNTX; // start time
                  ^~~~~
                  TCNT0
D:\Documents\Arduino\libraries\NeoSWSerial\src\NeoSWSerial.cpp:561:13: error: 'PCI_FLAG_REGISTER' was not declared in this scope
         if (PCI_FLAG_REGISTER & PCIbit) {
             ^~~~~~~~~~~~~~~~~

The code compiles for for a 16Mhz crystal. The only change appears to be the specification of -DF_CPU=20000000L

FRCIndustries commented 1 year ago

Was able to get around this by adding the following code in the c file under #if F_CPU == 16000000L

`#elif F_CPU == 20000000L

define TCNTX TCNT0

define PCI_FLAG_REGISTER PCIFR`