Ds1307rtc library stops any program running on my r4 wifi

Hi All
Have an issue with with a new board replacement.
I was using a Arduino UNO and the below code worked as it should.
I swapped the board today for a Arduino R4 wifi and the same program uploads with no errors but does not run.
I have tried uploading some of the example sketches which upload with no issues and work as intended.
Any help would be appreciated.

#include <SolarPosition.h>
#include <DS1307RTC.h>

const uint8_t digits = 3;

// some test positions:
SolarPosition Home(42.898551, -12.539774);  // Home//RTC CODE
int sun_position;


const int encoder_a = 2; // Green - pin 2 - Digital
const int encoder_b = 3; // White - pin 3 - Digital
long encoder = 690;

int trackerAzimuthAngle; 
int start=0;
int limitSwitchPin = 8;
int azLimitSwitch = 0;
const int azMotorPinPositive = 11;
const int azMotorPinNegative = 12;


int hours; int minutes; int seconds;


void setup() {
  Serial.begin(9600);
  pinMode(encoder_a, INPUT_PULLUP);
  pinMode(encoder_b, INPUT_PULLUP);

  attachInterrupt(0, encoderPinChangeA, CHANGE);
  attachInterrupt(1, encoderPinChangeB, CHANGE);

  pinMode(13, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(limitSwitchPin, INPUT);
  pinMode(azMotorPinPositive, OUTPUT);
  pinMode(azMotorPinNegative, OUTPUT);

  // set the Time service as the time provider//RTC CODE
  SolarPosition::setTimeProvider(RTC.get);
      
}

void loop() {
  azLimitSwitch = digitalRead(limitSwitchPin);

  if(start<1){
    homing();
    } // Send tracker back to home position if power enabled    
    start ++;

  rtcCode();

  if(hours > 12){
   running();
   Serial.print("RUNNING "); Serial.print('\n');}
   else{Serial.print("Waiting ");Serial.print('\n');
    }

  if(hours == 13 && minutes == 39 && seconds == 0){
    homing();}
      
  delay(1000);
}

void homing() {
  digitalWrite(azMotorPinNegative, HIGH);
  digitalWrite(azMotorPinPositive, HIGH);
    while(digitalRead(limitSwitchPin) == HIGH) {
        Serial.print("HOMING");// Change this to move the motor
          Serial.print('\n');
            digitalWrite(azMotorPinNegative, LOW);
          }
      digitalWrite(azMotorPinNegative, HIGH);

    while(digitalRead(limitSwitchPin) == LOW){
        Serial.print("BACKING OFF");//Change this to move motor
          Serial.print('\n');
          digitalWrite(azMotorPinPositive, LOW);
                  encoder = 0;// Check this in main program
        }
        digitalWrite(azMotorPinPositive, HIGH);
     }  

void running(){
  trackerAzimuthAngle = encoder/6.7;//change to degrees
  if(sun_position > trackerAzimuthAngle){
    digitalWrite(azMotorPinPositive, LOW);}
       else{digitalWrite(11, HIGH);}

  Serial.print("start ");
  Serial.print(start);
  Serial.print('\n');//establish if the program has just started
  Serial.print("Tracker Azimuth Angle =  ");
  Serial.println(trackerAzimuthAngle);  
  }

void rtcCode(){
printTime(RTC.get());
Serial.print(F("Home:\t"));
printSolarPosition(Home.getSolarPosition(), digits);
Serial.println();
Serial.print('\n');
} 

void encoderPinChangeA() {
   encoder += digitalRead(encoder_a) == digitalRead(encoder_b) ? -1 : 1;
}

void encoderPinChangeB() {
  encoder += digitalRead(encoder_a) != digitalRead(encoder_b) ? -1 : 1;
}


void printSolarPosition(SolarPosition_t pos, int numDigits)
{
  Serial.print(F("el: "));
  Serial.print(pos.elevation, numDigits);
  Serial.print(F(" deg\t"));

  Serial.print(F("az: "));
  Serial.print(pos.azimuth, numDigits);
  Serial.println(F(" deg"));  
  sun_position=(pos.azimuth);
  
}

void printTime(time_t t)
{
  tmElements_t someTime;
  breakTime(t, someTime);

  Serial.print(someTime.Hour);
  Serial.print(F(":"));
  Serial.print(someTime.Minute);
  Serial.print(F(":"));
  Serial.print(someTime.Second);
  Serial.print(F(" UTC on "));
  Serial.print(dayStr(someTime.Wday));
  Serial.print(F(", "));
  Serial.print(monthStr(someTime.Month));
  Serial.print(F(" "));
  Serial.print(someTime.Day);
  Serial.print(F(", "));
  Serial.println(tmYearToCalendar(someTime.Year));

  hours = someTime.Hour; minutes = someTime.Minute; seconds = someTime.Second;
    
    
}


You should always this format when using attach interrupt

attachInterrupt(digitalPinToInterrupt(pin), ISR, mode)

Hi Thanks
I am very new to this and that part of the code came from a library.
Would what you are saying stop the program running as it worked fine on the old board?

It doesn't even begin to run.

It could, since pin 2 may not be interrupt 0 on an R4

Ok I see.
Ill try blocking that part of the code out and see if it makes any difference.

So you don't get anything on serial monitor?
Or "not run" means something else?

No, You need to change the code to this

 attachInterrupt((digitalPinToInterrupt(2), encoderPinChangeA, CHANGE);
 attachInterrupt((digitalPinToInterrupt(3), encoderPinChangeB, CHANGE);

Hi Thanks
I've tried changing this and get this error "Compilation error: expected ')' before ';' token"

void setup() {
  Serial.begin(9600);
  pinMode(encoder_a, INPUT_PULLUP);
  pinMode(encoder_b, INPUT_PULLUP);

  //attachInterrupt(0, encoderPinChangeA, CHANGE);
  //attachInterrupt(1, encoderPinChangeB, CHANGE);
 attachInterrupt((digitalPinToInterrupt(2), encoderPinChangeA, CHANGE);
 attachInterrupt((digitalPinToInterrupt(3), encoderPinChangeB, CHANGE);

Hi
Get nothing at all on the serial monitor or from the board to the relays etc.

Sorry a typo, too many parentheses
This is correct

 attachInterrupt(digitalPinToInterrupt(2), encoderPinChangeA, CHANGE);
 attachInterrupt(digitalPinToInterrupt(3), encoderPinChangeB, CHANGE);

Hi Thank you
Still does nothing. Is there anything else I need to change along with this?

void setup() {
  Serial.begin(9600);
  pinMode(encoder_a, INPUT_PULLUP);
  pinMode(encoder_b, INPUT_PULLUP);

  //attachInterrupt(0, encoderPinChangeA, CHANGE);
  //attachInterrupt(1, encoderPinChangeB, CHANGE);
 attachInterrupt(digitalPinToInterrupt(2), encoderPinChangeA, CHANGE);
 attachInterrupt(digitalPinToInterrupt(3), encoderPinChangeB, CHANGE);

What is connected to pin 13?

change
long encoder = 690;
to
volatile long encoder = 690;

Nothing on pin 13. The code relating to that was just for testing.

Ill try this. Thank you

Still nothing.

const int encoder_a = 2; // Green - pin 2 - Digital
const int encoder_b = 3; // White - pin 3 - Digital
//long encoder = 690;
volatile long encoder = 690;

Since I don't own an R4, I don't think I can be of any further help.
The R4 is quite different from the R3 and not all libraries that work on the R3 will work on the R4. The SolarPosition library may not be compatible but I have no way of testing.

Hopefully someone with an R4 will join soon and can test the code.

You may want to change your title to "program won't run on Uno R4"

Ok thank you for your help and will take your advice on the program name.

So not an upload problem and hence your topic has been moved to a more suitable location on the forum.