RTC DS3132 et interruption
bonjour,je souhaite que la RTC declenche une interruption sur le pin 2 de l'arduino UNO.
J'ai d'abord essayé par scrutation,ça fonctionne:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| const uint8_t alarmInput(2);
void setup()
{
Serial.begin(9600);
pinMode(2, INPUT_PULLUP);
// initialize the alarms to known values, clear the alarm flags, clear the alarm interrupt flags
RTC.setAlarm(ALM1_MATCH_DATE, 0, 0, 0, 1);
RTC.setAlarm(ALM2_MATCH_DATE, 0, 0, 0, 1);
RTC.alarm(ALARM_1);
RTC.alarm(ALARM_2);
RTC.alarmInterrupt(ALARM_1, false);
RTC.alarmInterrupt(ALARM_2, false);
RTC.squareWave(SQWAVE_NONE);
// set Alarm 1 to occur at 5 seconds after every minute
RTC.setAlarm(ALM1_MATCH_SECONDS, 5, 0, 0, 0);
// clear the alarm flag
RTC.alarm(ALARM_1);
// configure the INT/SQW pin for "interrupt" operation (disable square wave output)
RTC.squareWave(SQWAVE_NONE);
// enable interrupt output for Alarm 1
RTC.alarmInterrupt(ALARM_1, true);
Serial.println(" Start ");
//attachInterrupt(digitalPinToInterrupt(2),printTime,LOW);
}
void loop()
{
// check to see if the INT/SQW pin is low, i.e. an alarm has occurred
if ( !digitalRead(alarmInput) )
{
printTime();
}
}
void printTime()
{
RTC.alarm(ALARM_1);
Serial.println("ça marche");
} |
Par contre lorsque je fonctionne par interruption:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| #include <DS3232RTC.h> // https://github.com/JChristensen/DS3232RTC
// pin definitions
const uint8_t alarmInput(2);
void setup()
{
Serial.begin(9600);
pinMode(2, INPUT_PULLUP);
// initialize the alarms to known values, clear the alarm flags, clear the alarm interrupt flags
RTC.setAlarm(ALM1_MATCH_DATE, 0, 0, 0, 1);
RTC.setAlarm(ALM2_MATCH_DATE, 0, 0, 0, 1);
RTC.alarm(ALARM_1);
RTC.alarm(ALARM_2);
RTC.alarmInterrupt(ALARM_1, false);
RTC.alarmInterrupt(ALARM_2, false);
RTC.squareWave(SQWAVE_NONE);
// set Alarm 1 to occur at 5 seconds after every minute
RTC.setAlarm(ALM1_MATCH_SECONDS, 5, 0, 0, 0);
// clear the alarm flag
RTC.alarm(ALARM_1);
// configure the INT/SQW pin for "interrupt" operation (disable square wave output)
RTC.squareWave(SQWAVE_NONE);
// enable interrupt output for Alarm 1
RTC.alarmInterrupt(ALARM_1, true);
Serial.println(" Start ");
attachInterrupt(digitalPinToInterrupt(2),printTime,LOW);
}
void loop()
{
}
// procedure interruption
void printTime()
{
RTC.alarm(ALARM_1);
Serial.println("ça marche");
} |
l'appel à l'ISR ne se fait pas,le pin 2 passe bien à 0,mais sans resultat.Quelqu'un a t'il une idée ??