i have this configuration:
Arduino DUE
Adafruit Ultimate GPS breackout V3
Adafruit TFT LCD 2.8" touchscreen
The GPS is connected to DUE Serial1 (pin 18, 19).
The LCD is connected via SPI (because i'm planning to use the sd-card slot).
The GPS and the LCD work fine alone, but when i put the sketch together the DUE freeze in setup() method when i call tft.begin().
But if i comment the parsing instruction [GPS.parse(GPS.lastNMEA())] in loop(), the sketch run ok.
Code: Select all
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "Adafruit_GPS.h"
// For the Adafruit shield, these are the default.
#define TFT_DC 9
#define TFT_CS 10
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// GPS
#define gpsSerial Serial1
Adafruit_GPS GPS(&gpsSerial);
void setup() {
Serial.begin(115200);
Serial.println("Start SETUP!");
Serial.println("Setup GPS");
GPS.begin(9600);
gpsSerial.begin(9600);
GPS.sendCommand(PMTK_SET_BAUD_9600);
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_5HZ);
GPS.sendCommand(PGCMD_NOANTENNA);
Serial.println("Setup TFT");
tft.begin();
Serial.println("Setup TFT begin finish");
tft.setRotation(3); // Landscape destra (cavi a sinistra)
tft.fillScreen(ILI9341_BLACK);
Serial.println("Setup finish!");
}
void loop(void) {
// read data from the GPS in the 'main loop'
char c = GPS.read();
//if (c) Serial.print(c);
if (GPS.newNMEAreceived()) {
Serial.println(GPS.lastNMEA()); // this also sets the newNMEAreceived() flag to false
// IF I UNCOMMENT THIS 2 LINE THE SKETCH FREEZE on tft.begin();
// if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false
// return;
updateFixGps(GPS.fix);
}
}
void updateFixGps(bool state) {
if(state) {
tft.fillCircle(68, 19, 10, ILI9341_GREEN);
} else {
tft.fillCircle(68, 19, 10, ILI9341_RED);
}
tft.drawCircle(68, 19, 10, ILI9341_WHITE);
}
How can i verify it ?
And if is really a memory problem, how can i fix it ?
Thanks