Combining DeadOn RTC and 16x32 LED Matrix

Hello,
I am trying to display the time of the DeadOn RTC clock in the 16x32 RGB LED Matrix,
DeadOn RTC: https://www.sparkfun.com/products/10160
16x32 RGB LED Matrix: https://www.adafruit.com/products/420

#include <SPI.h>
#include <Adafruit_GFX.h>   // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library

#define CLK 50  // MUST be on PORTB!
#define LAT A3
#define OE  51
#define A   A0
#define B   A1
#define C   A2

const int  cs=53; //chip select 

// Last parameter = 'true' enables double-buffering, for flicker-free,
// buttery smooth animation.  Note that NOTHING WILL SHOW ON THE DISPLAY
// until the first call to swapBuffers().  This is normal.
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, true);
        
void setup () {
  Serial.begin(9600);
  
  RTC_init();
  //day(1-31), month(1-12), year(0-99), hour(0-23), minute(0-59), second(0-59)
  SetTimeDate(11,12,13,14,15,16); 
  
  matrix.begin();
  matrix.setTextSize(1);
}

void loop () {
  // Clear background
  matrix.fillScreen(0);
  
  Serial.println(ReadTimeDate());
  
  matrix.setCursor(0, 0);
  matrix.print(ReadTimeDate());
  
  // Update display
  matrix.swapBuffers(false);
  
  delay(1000);

}


//=====================================
int RTC_init(){ 
	  pinMode(cs,OUTPUT); // chip select
	  // start the SPI library:
	  SPI.begin();
	  SPI.setBitOrder(MSBFIRST); 
	  SPI.setDataMode(SPI_MODE1); // both mode 1 & 3 should work 
	  //set control register 
	  digitalWrite(cs, LOW);  
	  SPI.transfer(0x8E);
	  SPI.transfer(0x60); //60= disable Osciallator and Battery SQ wave @1hz, temp compensation, Alarms disabled
	  digitalWrite(cs, HIGH);
	  delay(10);
}
//=====================================
int SetTimeDate(int d, int mo, int y, int h, int mi, int s){ 
	int TimeDate [7]={s,mi,h,0,d,mo,y};
	for(int i=0; i<=6;i++){
		if(i==3)
			i++;
		int b= TimeDate[i]/10;
		int a= TimeDate[i]-b*10;
		if(i==2){
			if (b==2)
				b=B00000010;
			else if (b==1)
				b=B00000001;
		}	
		TimeDate[i]= a+(b<<4);
		  
		digitalWrite(cs, LOW);
		SPI.transfer(i+0x80); 
		SPI.transfer(TimeDate[i]);        
		digitalWrite(cs, HIGH);
  }
}
//=====================================
int ReadTimeDate(){
	int temp;
	int TimeDate [7]; //second,minute,hour,null,day,month,year		
	for(int i=0; i<=6;i++){
		if(i==3)
			i++;
		digitalWrite(cs, LOW);
		SPI.transfer(i+0x00); 
		unsigned int n = SPI.transfer(0x00);        
		digitalWrite(cs, HIGH);
		int a=n & B00001111;    
		if(i==2){	
			int b=(n & B00110000)>>4; //24 hour mode
			if(b==B00000010)
				b=20;        
			else if(b==B00000001)
				b=10;
			TimeDate[i]=a+b;
		}
		else if(i==4){
			int b=(n & B00110000)>>4;
			TimeDate[i]=a+b*10;
		}
		else if(i==5){
			int b=(n & B00010000)>>4;
			TimeDate[i]=a+b*10;
		}
		else if(i==6){
			int b=(n & B11110000)>>4;
			TimeDate[i]=a+b*10;
		}
		else{	
			int b=(n & B01110000)>>4;
			TimeDate[i]=a+b*10;	
			}
	}
//	temp.concat(TimeDate[4]);
//	temp.concat("/") ;
//	temp.concat(TimeDate[5]);
//	temp.concat("/") ;
//	temp.concat(TimeDate[6]);
//	temp.concat("     ") ;
//	temp.concat(TimeDate[2]);
//	temp.concat(":") ;
//	temp.concat(TimeDate[1]);
//	temp.concat(":") ;
//	temp.concat(TimeDate[0]);
        temp=TimeDate[0];
  return(temp);
}

But with this code the matrix does not show anything, what’s the problem?

Thank you

what's the problem?

  matrix.print(ReadTimeDate());

So, this will show the value returned by the function:

int ReadTimeDate(){

which is:

        temp=TimeDate[0];
  return(temp);

So, what is in TimeDate[0] at this time?

In the serial monitor with this code:

Serial.println(ReadTimeDate());

prints the seconds.

Does RGBmatrixPanel derive from the Print class? If not, what kinds of variables does it know how to print()?

Matrix printing both variables of string type and integer type, the problem comes when I initialize the RTC:

RTC_init();
//day(1-31), month(1-12), year(0-99), hour(0-23), minute(0-59), second(0-59)
SetTimeDate(11,12,13,14,15,16);

The only common pins are MISO = 50, MOSI=51 (Arduino Mega ADK). Is that the problem?

Thank You

Is that the problem?

Those are the SPI pins.

Each SPI device needs a separate chip/slave select pin. It is not at all clear what value cs has in it, in the RTC_init() function. It is not clear if the matrix class properly diddles with its chip select pin.

i have same problem . i want to make a wall clock with 16x32 LED Matrix but it crash when i use matrix.println(rtc.getTimeStr()); or Serial.println(rtc.getTimeStr());

it works sperately. How can i combine .

but it crash when i use

What do?

Where is your code? Which Arduino are you using? Please feel free to volunteer any other information that you know that we don’t.