Forum Replies Created
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
October 11, 2020 at 2:54 PM in reply to: Is it possible to use RTCZero and External Interrupts #15749YendorParticipant
Ok I think I found it, I was using pin 5 and 6 for the interrupts, but 2, 3, 5 and 6 are used for the radio. Changed to 10 and 11 and its not crashing anymore.
Thanks for your time.
October 11, 2020 at 2:10 PM in reply to: Is it possible to use RTCZero and External Interrupts #15748YendorParticipantThanks for the reply,
I was just about to post a update, anyway I did up a test program and it works but I do get a unrecognised device for the USB when I run this code. But still unable to run the full code with out it crashing when adding the interrupts.working test code:
#include <RTCZero.h> #define Serial SerialUSB void interrupt_handler(); const byte button = 5; const int32_t TX_INTERVAL = 5; bool ledIsOn = false; int32_t buttonCount; int32_t startTime; int32_t sleepTime; RTCZero rtc; void setup() { rtc.begin(); rtc.setEpoch(0); // pinMode(button, INPUT_PULLUP); pinMode(digitalPinToInterrupt(button), INPUT_PULLUP); pinMode(LED_BUILTIN, OUTPUT); Serial.begin(115200); // delay(5000); Serial.println(F("Adding Interrupt")); // delay(250); attachInterrupt(button, interrupt_handler, LOW); Serial.println(F("Testing Interrupt")); // delay(250); } void loop() { startTime = rtc.getEpoch(); sleepTime = TX_INTERVAL - (rtc.getEpoch() - startTime); if (sleepTime < 1) sleepTime = 1; if (sleepTime > TX_INTERVAL) sleepTime = TX_INTERVAL; rtc.setAlarmEpoch(rtc.getEpoch() + sleepTime); rtc.enableAlarm(rtc.MATCH_YYMMDDHHMMSS); // Serial.println(F("Now going to sleep")); Serial.flush(); rtc.standbyMode(); // Serial.println(F("I am awake")); digitalWrite(LED_BUILTIN, ledIsOn = !ledIsOn); } void interrupt_handler() { // Serial.println(F("Interruption triggered")); digitalWrite(LED_BUILTIN, ledIsOn = !ledIsOn); }
can you suggest any thing else that maybe causing the crash or how to trap the error?
Regards
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)