![]() But I have no ideas what this program does not work. I just want to have a program that first: reads values from clock and second: count the number of interrupts in one second period. Maybe it is necessary that I mention that the second part of the program has nothing to do with the first (so measuring interrupts from hall effect sensor and reading time values from DS1307 chip are two separate things). Maybe it is better to imagine that the first part of the program (// Wire) reads time values from the DS1307 chip (as in example in void get_time() on this page: Simple Labs' Quick Start Kit for Arduino: Simple Labs' Quick Start Kit for Arduino - DS1307 Real Time Clock IC Interfacing- How To?) and the second part of the program (// Interrupt) counts the number of interrupts (actually rising signal, let say from the hall effect sensor) from Arduino digital input D2 (interrupt 0 location on Arduino Mega) in the time period of one second. I can provide (quite longer) program which do something useful but this doesn't make sense for me. Sorry that I forget to point out (it was obviously for me) that the program does nothing sensible but it is just (minimal) example that using Wire library together with interrupts don't work in the provided example. I would like to thank you for all your answers! Now, what did you actually want it be doing? ![]() Turning off interrupts is also going to complicate things. This will cause the interrupt routine to increment puls but you don't do anything with it so I can't see how you know whether or not the clock is interrupting. If it does, and if you have the SQW signal connected to the correct pin, an interrupt will occur once every second. I think the RTC might, by default, output a 1Hz signal. ![]() This prints a message, turns interrupts on (why?), waits a second, turns interrupts off (WHY?) and prints another message (with interrupts off, maybe it doesn't print). ![]() It is also NOT a good idea to send to the clock so frequently because it will make the clock drift much faster than it would normally. This just tells the realtime clock that you are going to read or write to/from its register zero, but then you do neither. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |