Inability to trigger alarm

I have been trying to make my own project with an Arduino Machine Control. At this point i was making my own set of alarms and everything was fine and almost finished. Closed the arduino and the pc for the day, that was 2 days ago. Since yesterday i have been trying to trigger the alarms but they never go off now.
The Machine control library example Arduino_MachineControl/examples/RTC_Alarm/RTC_Alarm.ino at master · arduino-libraries/Arduino_MachineControl · GitHub
was working fine and now the alarm never triggers.
Any thoughts?

Use code tags to display the code and show a circuit diagram - seems like a power issue

Let's say this is the code:

/*
  Machine Control - RTC Alarm Example

  This sketch shows how to use the RTC PCF8563T on the Machine
  Control Carrier and how to configure and use the PCF8563T's
  alarm.

  Circuit:
   - Portenta H7
   - Machine Control

*/
#include <Arduino_MachineControl.h>

using namespace machinecontrol;

int hours = 12;
int minutes = 45;
int seconds = 57;

void callback_alarm();

bool alarm_flag = false;

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect.
  }
  Serial.println("Initialization");

  if (!rtc_controller.begin()) {
    Serial.println("Initialization fail!");
  }


  Serial.println("Initialization Done!");

  // APIs to set date's fields: hours, minutes and seconds
  rtc_controller.setHours(hours);
  rtc_controller.setMinutes(minutes);
  rtc_controller.setSeconds(seconds);
  // Enables Alarm on PCF8563T
  rtc_controller.enableAlarm();

  // set the minutes at which the alarm should rise
  rtc_controller.setMinuteAlarm(46);

  // Attach an interrupt to the RTC interrupt pin
  attachInterrupt(RTC_INT, callback_alarm, FALLING);

  Serial.println();
}
int counter = 1;
void loop() {
  if (alarm_flag) {
    Serial.println("Alarm!!");
    Serial.println("Alarm!!");
    Serial.println("Alarm!!");
    Serial.println("Alarm!!");
    Serial.println("Alarm!!");
    Serial.println("Alarm!!");
    detachInterrupt(RTC_INT);
    rtc_controller.setSeconds(seconds);
    rtc_controller.setMinuteAlarm(minutes + counter);
    rtc_controller.clearAlarm();
    attachInterrupt(RTC_INT, callback_alarm, FALLING);
    alarm_flag = false;

    // To disable the alarm uncomment the following line:
    // rtc_controller.disableAlarm();
  }

  // APIs to get date's fields.
  //Serial.println(digitalRead(rtc_controller.int_pin));
  Serial.print(rtc_controller.getHours());
  Serial.print(":");
  Serial.print(rtc_controller.getMinutes());
  Serial.print(":");
  Serial.println(rtc_controller.getSeconds());
  delay(1000);
}

void callback_alarm () {
  alarm_flag = true;
}

And there is no circuit just an Arduino Machine Control connected with a USB. Just for reference.

Is there a way to check and fix the power issue?

Let me point out the fact that the Clock is working properly. It is the interrupt, only, that does not.

So you say. I assume that means that it is printing plausible times, times for which the alarm should have gone off.

Also, I don't think it is your problem, but there should be no need to attach and detach the interrupt. After first attaching it in setup() of course.

Things that worked then don't are frustrating but you should revisit anything that changed and anything that could have changed between then and now. A wire falls out of place, a battery runs out and so froth.

a7

My original code is based on this example. It is a jumbled mess as it is not complete. The thing is if this example works, my code works. For some reason, without any hardware or software change, even this example stopped working. I tried reinstalling libraries, bootloader, using it on a different portenta (although i dont have a 2nd Machine Control), and nothing works so far. Right now im trying to test other libraries but so far no progress.
Machine Control's RTC chip seems to be PCF8563 with PB_9 interrupt pin, if you have any RTC libraries that will work on it with one or multiple alarms, I will make them fit to my code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.