I have a ds3231 rtc module. I am very happy with. Currently I have it working on my mega 2650 with an lcd and keypad membrane. it displays current time, date, temperature etc.
I have functions to set the time and the alarm which are working. I can read out the alarm time on the lcd set alarm time with print alarm function. First when I set the alarm, I stored the alarm figures in variables in the mega, worked fine, it got me out bed.
but ofc, when I have a power failure at night, the alarm gets resetted. So I decided to use the alarm 1 register of the rtc. setting the alarm registers was ez. But I am getting no interrupt signal on the SQW pin of the RTC.
to activate the alarm I do the following.
Wire.write(0x0E); // control register address
Wire.write(0b00000101); // put INTCON at 1 to remove pwm on the pin and allows alarm to trigger an interrupt
Wire.endTransmission(); // put A1IE at 1 to enable alarm 1 so that interrupt will happen on a match of time and alarm
Wire.write(0x07); // alarm seconde adres
Wire.write(0x00); // seconde
Wire.write(DecToBcd(alarm_minuut)); // minuten
Wire.write(DecToBcd(alarm_uur)); // uren
Wire.write(0b10000000 + DecToBcd(datum)); // datum <<< THIS is cuz; I need to make the MSB of address 0x0Ah HIGH
Wire.endTransmission(); // so that alarm is triggered only on match of seconds, minutes and hours
I connect the interrupt pin with a 4k7 R to 5V and this line should activate my ISR; attachInterrupt(5, ALARM, CHANGE);
ALARM is the ISR.
I tried everything; different interrupt pins, no pullup R, 5, alarm, FALLING, Wire.write(0x0E); Wire.write(0b0000101)// (one less 0), name it and I tried it.
Can anyone tell me what I am doing wrong?
I think I will just take alarm 2 because it has no second match, and thus one potential problem less to care about -_-.
Also I am making use of a timer library <Timer.h> idk if this can influence the interrupts??