![]() ![]() I also made it a CHANGE interrupt so you get both the rising and falling pulse. This is correct: attachInterrupt (digitalPinToInterrupt (rtcTimerIntPin), rtc_interrupt, CHANGE) You need an interrupt number, not a pin number. I happened to have a DS3231 lying around so I made up a test.įirst, this is wrong in your code: attachInterrupt(rtcTimerIntPin, rtc_interrupt, RISING) This answer addresses the original question of why the interrupts didn't work. Serial.println("Clock did not lose power") ĪttachInterrupt(rtcTimerIntPin, rtc_interrupt, RISING) ĭigitalWrite(LED_BUILTIN, HIGH) // flash the ledĭigitalClockDisplay() // this just prints time to serial portĭigitalWrite(LED_BUILTIN, LOW) // turn off ledįlag = false // clear the flag until timer sets it again Time_t newTime = cvt_date(_DATE_, _TIME_) ![]() Serial.println("Detected clock power loss - resetting RTC date") Serial.println("RTC has set the system time") Serial.println("Unable to sync with the RTC") SetSyncProvider(gRTC.get) // the function to get the time from the RTC Here is some simple code for a sketch that I think should trigger a 1 second interrupt and call my function: #include // I also added a led in the circuit to see if I could figure out something that way, but no dice. I followed what I thought was the wiring diagram here and I tried to use the square wave to trigger a call back/interrupt, but it's not working for me. Can someone point me to a reference for this? So my question is, could somebody rewrite the code below (register names etc) so it works on an Arduino Nano Every, or point me to somewhere that explains how to do it succinctly (i.e.I am able to set up one hz interrupts using millis and other timers, but would like to do it instead using the RTC I have attached ( DS3231) I found the link below, but it's no help as it doesn't compile for me. I've got the ATMega 4808/4809 datasheet and will at some point crunch my way through it and hopefully eventually understand how to set up a timer ISR on a Nano Every from first principles, but right now I'm being lazy and would just like the damn thing to work. Which means that the bit where my code sets up a timer interrupt does not compile. But since it runs on a different processor, the register architecture and names have been changed around. ![]() Sounded like exactly what I needed, so I got two of these. Pin-compatible with the original Nano but with 50% more program memory. Then I've heard of the new Arduino Nano Every. In any case, it works well as it is, we've had one in the lab where I work for close to a year now and I've recently had to build a second one because of high/near constant demand. At some point I will rewrite this to talk to a PC-based client which will dispense with the user interface and free a lot of the memory, but I'm not there yet (learning C++ as I go along). This is mostly because it includes a complete menu-driven user interface (with ANSI colour/cursor control etc) via PuTTY. I would like to add some extra functionality and several more pH buffer temperature dependence tables, but as it is, the program code takes 99% of the available memory. I have a pH/temperature logger based on an Arduino Nano. I've been reading the forums for quite a while but this is my first message here so apologies if I've chosen the wrong section or otherwise flouted some rule I wasn't aware of. First off, a big thank you to all the contributors to these forums, they are an invaluable learning and reference resource. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |