Second:
groundFungus : I am confused by your remark concerning SDA and SCL pins.
I started my project on an UNO and needed to upgrade to a MEGA due to a lack of memory and pins.
On the UNO A4 is shorted to SCL and A5 to SDA next to the Aref pin, as you say.
It is still working on the MEGA and according to you It should not!
So I studied more in detail the schematics of the RTC Shield I implemented on top of my MEGA, and bingo, you are right: the SDA and SCL reaches the RTC not via A4 and A5, but via SCL and SDA on pin 20 and 21!
Thank you for your remarck! this frees the A4 and A5 pins for other uses!
Concerning the Interruption: as you can see on the diagram (I succeded to insert it in my post thanks to PerryBebbington)
the interruption signal of the RTC is indeed open collector, and I pull-upped it with a 8.2K (out of stock of 10K).
I monitorred this signal on a scope and I see it going up after initialisation and going down after my 10s alarm request.
This leads me to think that electronicaly it seems to work normally.
My code is very long so I try some extraction of the meaningfull parts:
And I am French, so sorry for the French comments...
This is the include and var definition part
#include <RTClib.h>//C:\Documents and Settings\Administrateur\Mes documents\Arduino\libraries\RTClib-master
RTC_PCF8523 rtc;//pcf8523 sur Adafruit Datalogger shield rev B
//variable pour l'alarme
#define PIN_ALARM_RTC 2
volatile Pcf8523TimerState RTC_etat_TIMER;
volatile bool AlarmRTC = false;
DateTime DateDerniereAcquis;
this is the initialisation part:
rtc.writeSqwPinMode(PCF8523_OFF);//pas de signaux carrés sur INT1_
pinMode(PIN_ALARM_RTC, OUTPUT);
digitalWrite (PIN_ALARM_RTC, HIGH);//just to be sure it start at HIGH
pinMode(PIN_ALARM_RTC, INPUT);
RTC_etat_TIMER.enabled = true;/** whether the timer is running */
RTC_etat_TIMER.value = 10;/** the current value of the timer */
RTC_etat_TIMER.freq = PCF8523_Freq_second;/** the clock divider used */
RTC_etat_TIMER.irupt_state.irupt_flag = false;/** the timer's interrupt state */
RTC_etat_TIMER.irupt_state.irupt_enabled = true;//on active l'IT donc on desactive CLKOUT
rtc.write_timer(PCF8523_Timer_Countdown_A, &RTC_etat_TIMER);
attachInterrupt(PIN_ALARM_RTC, onAlarmRTC, FALLING );//ne marche pas CHANGE
And this is my IT routine
void onAlarmRTC() {
noInterrupts();
AlarmRTC = true;
interrupts();
}
In my main loop
void loop(void){
if (AlarmRTC){
Serial.println("---------------------------");
Serial.println("Alarme RTC :");
....
/
if (AlarmRTC) triggers always ...
.........
Heuuuurgl! as I wrote this post, I discover that nowhere in my program the boolean 'AlarmRTC' is set back to False...
I think that was the problem!
..... I feel so confused,
Formulating correctely the question, is halfway to answering to it
But my first question remains: which functions (delay, PWM , I2C, or other I don't know) uses INT0 which might interfere with other ?
Thank you again for all your usefull remarks!
And really sory to use your time on my mistakes!