[solution in the last post]
Hey! ![]()
I want to use the Adafruit Ultimate GPS Breakout v3 with the Adafruit_GPS library.
I'vve connected an Arduino Mega2560.
I'm using the Hardwareserial due to an overlapping on some vector data storage adress things with the pin_change_int library, which i use for some interrupts on a few analog pins.
Link to an forum post where they discuss this problem.
I tested the module with Softwareserial and everythings worked. But when i switched to Hardwareserial, one line of code made it to crash.
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
I tried to test it with the parse.pde example and again, same line caused the crash.
So i think i have three options:
- Either i use an other library for the interrupts (i cant use the default ones on the mega, because i use them for other sensors like an Adafruit_BNO055).
- Or we find the solution to the problem with this misterious line.
- Or I remove the line. Do i really need that line by the way?
Here is the entire code i used to find the line causing the crash. When i comment the line out, everything works just fine.
#include <Adafruit_GPS.h>
HardwareSerial mySerial = Serial1;
Adafruit_GPS GPS(&mySerial);
void setup()
{
Serial.begin(115200);
Serial.println("setup");
GPS.begin(9600);
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // this line here causes the crash!
// interrupt things
OCR0A = 0xAF;
TIMSK0 |= _BV(OCIE0A);
delay(1000);
mySerial.println(PMTK_Q_RELEASE);
}
SIGNAL(TIMER0_COMPA_vect) {
char c = GPS.read();
}
uint32_t timer = millis();
void loop()
{
if (GPS.newNMEAreceived()) {
if (!GPS.parse(GPS.lastNMEA()))
return;
}
if (timer > millis()) timer = millis();
if (millis() - timer > 2000)
{
timer = millis();
// print some data
Serial.print("\nTime: ");
Serial.print(GPS.hour, DEC); Serial.print(':');
Serial.print(GPS.minute, DEC); Serial.print(':');
Serial.print(GPS.seconds, DEC); Serial.print('.');
Serial.println(GPS.milliseconds);
}
}
Thank you for reading all this text!