WIP
попытка дебажить PPS/SQW. работа на SWSerial (8,9) вывод в консоль Serial и на LCD
This commit is contained in:
16
RTC_com.cpp
16
RTC_com.cpp
@@ -8,9 +8,13 @@
|
||||
#include <Arduino.h> // for all the 'standard' Arduino stuff
|
||||
#include <DS3232RTC.h> // https://github.com/JChristensen/DS3232RTC
|
||||
#include <TimeLib.h> // https://github.com/PaulStoffregen/Time [valid until year 2099, no 2038 bug]
|
||||
#include "GPS_RTC_Clock.h"
|
||||
#include "RTC_com.h"
|
||||
|
||||
#define cfg_pin_RTC_SQW 3;
|
||||
#ifndef DEBUG_PORT
|
||||
#define DEBUG_PORT Serial
|
||||
#endif
|
||||
|
||||
// add the static modifier to limit visibility of these variables to just this file
|
||||
static int ledPin_PPS = A6; // Pin for RTC PseudoPPS LED [analog PIN used as digital PIN]
|
||||
@@ -23,11 +27,9 @@ bool SyncErr = true;
|
||||
#include <DS3232RTC.h>
|
||||
DS3232RTC myRTC(0x68); // cfg_
|
||||
volatile bool RTC_sec = false; // flag for PseudoPPS
|
||||
static unsigned long RTCMillis; // blinking timer
|
||||
volatile unsigned long tmr_SQW;
|
||||
unsigned long RTCMillis; // blinking timer
|
||||
|
||||
void rtc_interrupt() {
|
||||
tmr_SQW = micros();
|
||||
//Serial.print("DEBUG[INT] RTC interrupt "); Serial.println(micros());
|
||||
RTCMillis = millis();
|
||||
RTC_sec = true;
|
||||
@@ -51,6 +53,9 @@ void RTC_setup() {
|
||||
void RTC_loop() {
|
||||
//Serial.println("DEBUG[RTC_loop()] Start");
|
||||
if (RTC_sec) { // do after RTC PseudoPPS interrupt, without interrupt NO time/date to display
|
||||
DEBUG_PORT.println("DEBUG[RTC_loop()] RTC_sec: " + String(RTC_sec));
|
||||
DEBUG_PORT.println("DEBUG[RTC_loop()] RTCMillis: " + String(RTCMillis));
|
||||
DEBUG_PORT.println("DEBUG[RTC_loop()] millis: " + String(millis()));
|
||||
RTC_sec = false; // clear flag
|
||||
digitalWrite(ledPin_PPS, LOW); // LED off
|
||||
time_t now_t = myRTC.get();
|
||||
@@ -60,6 +65,9 @@ void RTC_loop() {
|
||||
}
|
||||
Sec_Flip(now_t); // pass current datetime from RTC in UTC
|
||||
}
|
||||
else {
|
||||
NewSec = false;
|
||||
}
|
||||
if (millis() > (RTCMillis + 100)) { // do 100ms after PseudoPPS interrupt
|
||||
digitalWrite(ledPin_PPS, HIGH); // LED on
|
||||
}
|
||||
@@ -70,7 +78,7 @@ void SetRTC(time_t t) {
|
||||
last_sync_t = t;
|
||||
SyncErr = false;
|
||||
digitalWrite(ledPin_Sync, HIGH); // LED on
|
||||
Serial.println("RTC set by GPS"); // debug
|
||||
//Serial.println("RTC set by GPS"); // debug
|
||||
}
|
||||
|
||||
//End
|
||||
Reference in New Issue
Block a user