DS1307 adrress register help !

Its in the code halejandro:

RTC_write_command = incomingCommand & 0xF0; // mask off high byte <<< Make the byte equal to 0xsomething0
if (RTC_write_command == 0xF0){ // check for Write command <<< if the something was F, then continue
RTC_register = incomingCommand & 0x0F; // mask off low byte <<< Now make the byte equal to 0x0something
incomingCommand = 0; <<< reset the byte so we don't re-execute before a new command is read
new_data = incomingData; <<< read the data byte to send to the DS1307
Serial1.print (" Sending a command ");
switch (RTC_register){
case 0: // write seconds <<< now if the 0x0something == 0, do this case, or 1, or 2, etc.

I´m using the modulo operator with the ASCII chars, everything is fine with numbers but I don´t see the letters, to put together two nibbles, I´m doing the same you explained to me but when I introduce '1','0' the serial monitor shows 1,0 instead 10, what am I doing wrong ?

Show me what you have please.

byte incomingCommand = 0;
byte incomingData = 0;
byte receivedByte = 0;
byte Option_to_write = 0;

void setup(){
  Serial.begin(9600);
  Serial.flush();
}

void loop(){
  if (Serial.available()>2){
    incomingCommand = Serial.read();
    incomingData = Serial.read();
    
    receivedByte = incomingCommand%16;
    incomingData = receivedByte%16;
    Option_to_write = (incomingCommand << 4) + incomingData;    
    
    Serial.print("Command:");
    Serial.print(receivedByte, HEX);
    Serial.print(" Data:");
    Serial.print(incomingData, HEX);
    Serial.print(" Option to write:");
    Serial.println(Option_to_write, HEX);
    
  }
}

halejandro,
This code works with the Arduino's IDE Serial Monitor at 57,600
Please review & understand the change I made, I mostly left the old commands there so you can see the changes.

Commands are given as
F004, sets seconds to 04
F110, sets minutes to 10
F209, sets hours to 09
etc for F3, F4, F5, F6,F7

/*
Test of RTC DS1307 via I2C.
 Counts 
 Seconds, 
 Minutes, 
 Hours, 
 Date of the Month, 
 Month, 
 Day of the week, and 
 Year with Leap-Year
 
 56 bytes battery backed RAM
 Square Wave Output, can connect to INT2/D6 or PD7
 */

/*
Modified to Run thru IDE Serial port
*/
#include <Wire.h>

//variables
byte seconds_address = 0x00;
byte seconds; // bit 7 = Clock Halt, Enabled = 0, Halt = 1
// bits 6-5-3 = tens of seconds 0-6,  bits 3-2-1-0 = units of seconds, 0-9

byte minutes_address = 0x01;
byte minutes;  // bits 6-5-4 = tens of minutes, bits 3-2-1-0 = units of minutes

byte hours_address = 0x02; 
byte hours;  // 7=0. 6 = 1 for 12 hr, 0 for 24 hr.
// bit 5: 12 hr mode = AM(0)/PM(1). 24 hr mode = upper tens of hrs
// bit 4 =  lower tens of hrs, bits 3-2-1-0 = units of hours (0-9)

byte day_week_address = 0x03; 
byte day_week = 0; // range 01-07

byte date_month_address = 0x04;
byte date_month = 0; // range 01-31

byte month_address = 0x05;
byte month = 0; // range 01-12

byte year_address = 0x06;
int year = 0; // upper byte 0-9, lower byte 0-9

byte square_address = 0x07;
byte sqwe = 0;  // square wave enable
// Out-0-0-Sqwe-0-0-RS1-RS0
// Out, Sqwe = 0/0 - Square wave output = 0
// Out, Sqwe = 1/0 - Square wave output = 1
// Out, Sqwe = 0/1 or 1/1 - Square wave output per RS1/RS0
// RS1/RS0 = 00 = 1 Hz
// RS1/RSo = 01 = 4 KHz
// RS1/RS0 = 10 = 8 KHz
// RS1/RS0 = 11 = 32 KHz

byte RTC_ram_address = 0x08; //range = 08-63, 0x08-0x3F

int RTC_address = 0x68; // 1101 000 

byte incomingCommand = 0;
byte RTC_write_command = 0;
byte RTC_read_command = 0;
byte RTC_ram_command = 0;

// use F0xx, F1xx,F2xx, F3xx, F4xx, F5xx, F6xx, F7xx
// to send one register write commands
// use E0xx to read registers back - not coded yet
// use C0xx to read RAM back - not coded yet

byte incomingRegister = 0;
byte RTC_register = 0;
byte incomingData1 = 0;
byte incomingData2 = 0;
byte new_data = 0;
byte outgoingData = 0;
int delay_time = 100;

unsigned long currentMillis = 0;
unsigned long previousMillis = 0;
unsigned long duration = 5000;

void setup() {
  Wire.begin(); // no address, we are master
  Serial.begin (57600);  
  Serial.flush();
  currentMillis = millis();  
}

void loop() {

  if (Serial.available() >3){
    incomingCommand = Serial.read();
    incomingRegister = Serial.read();
    incomingData1 = Serial.read();
    incomingData1 = incomingData1 - 0x30; // convert ASCII to HEX
    incomingData2 = Serial.read();
    incomingData2 = incomingData2 - 0x30;  // convert ASCII to HEX
    new_data = (incomingData1 << 4) + incomingData2;  // put the Upper/Lower nibbles together
    Serial.print ("command ");
    Serial.println (incomingCommand);
    Serial.print ("register ");
    Serial.println(incomingRegister);
    Serial.print ("data1 ");
    Serial.println (incomingData1, HEX);
    Serial.print ("data2 ");
    Serial.println (incomingData2, HEX);
    Serial.print ("combined data ");    
    Serial.println (new_data, HEX);
    
  }
  // *******************************************
//  RTC_write_command = incomingCommand & 0xF0;  // mask off high byte
//  if (RTC_write_command == 0xF0){  // check for Write command
if ((incomingCommand == 'F') | (incomingCommand == 'f')){
  incomingCommand = 0;  // reset for next pass
//    RTC_register = incomingCommand & 0x0F;  // mask off low btye
//    incomingCommand = 0;
//    new_data = incomingData;
    Serial.println (" Sending a command ");
//    switch (RTC_register){
switch (incomingRegister){
  case '0': // write seconds
        Serial.println ("Seconds ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(seconds_address);          // queue the register
      Wire.send(new_data);                  // queue data
      Wire.endTransmission();            // send it
      delay (delay_time);
      break;
    case '1': // write minutes
    Serial.println ("Minutes ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(minutes_address);          // queue the register
      Wire.send(new_data);                  // queue data
      Wire.endTransmission();            // send it
      delay (delay_time);
      break;
    case '2': // write hours
        Serial.println ("Hours ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(hours_address);          // queue the register
      Wire.send(new_data);                  // queue data
      Wire.endTransmission();            // send it
     delay (delay_time);
      break;
    case '3': // write day
        Serial.println ("Day ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(day_week_address);          // queue the register
      Wire.send(new_data);                  // queue data
      Wire.endTransmission();            // send it
     delay (delay_time);
      break;
    case '4': // write date of month
        Serial.println ("Day of Month ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(date_month_address);          // queue the register
      Wire.send(new_data);                  // queue data
      Wire.endTransmission();            // send it
     delay (delay_time);
      break;
    case '5': // write month
        Serial.println ("Month ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(month_address);          // queue the register
      Wire.send(new_data);                  // queue data
      Wire.endTransmission();            // send it
     delay (delay_time);
      break;
    case '6': // write year
        Serial.println ("Year ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(year_address);          // queue the register
      Wire.send(new_data);                  // queue data
      Wire.endTransmission();            // send it
     delay (delay_time);
      break;
    case '7': // write square wave
        Serial.println ("Square Wave ");
    Serial.println (RTC_register, HEX);
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(square_address);          // queue the register
      Wire.send(new_data);                  // queue data
      Wire.endTransmission();            // send it
     delay (delay_time);
      break;
    case '8': // write RAM
        Serial.print ("RAM ");
    Serial.println (RTC_register, HEX);
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(RTC_ram_address);          // queue the register
      Wire.send(new_data);                  // queue data
      Wire.endTransmission();            // send it
     delay (delay_time);
      break;
      // all others,do nothing
      Serial.println ("Invalid command ");
    }  // end Switch
  } // end if command == 'F'
  // ************************************

  currentMillis = millis();
  if ( (currentMillis - previousMillis) >= duration){
    previousMillis = currentMillis;  
    // Reset the register pointer  
    Wire.beginTransmission(RTC_address);  
    Wire.send(0x00);  
    Wire.endTransmission();   

    Wire.requestFrom(RTC_address,8 );  
    seconds = Wire.receive();  
    minutes = Wire.receive();  
    hours = Wire.receive();  
    day_week = Wire.receive();  
    date_month = Wire.receive();  
    month = Wire.receive();  
    year = Wire.receive();  
    sqwe = Wire.receive();

    // Seconds 
    // bit 7 = Clock Halt, Enabled = 0, Halt = 1
    // bits 6-5-3 = tens of seconds 0-6,  bits 3-2-1-0 = units of seconds, 0-9 

    // Hours
    // 7=0. 6 = 1 for 12 hr, 0 for 24 hr.
    // bit 5: 12 hr mode = AM(0)/PM(1). 24 hr mode = upper tens of hrs
    // bit 4 =  lower tens of hrs, bits 3-2-1-0 = units of hours (0-9)

    Serial.print ("Hrs " );
    Serial.print (hours, HEX);
    Serial.print (" Mins ");
    Serial.print (minutes, HEX);
    Serial.print (" Secs ");
    Serial.print (seconds, HEX);
    Serial.print (" Day ");
    Serial.print (day_week, HEX);
    Serial.print (" Date ");
    Serial.print (date_month, HEX);
    Serial.print (" Month ");
    Serial.print (month, HEX);
    Serial.print (" Year 20");
    Serial.print (year, HEX);
    Serial.print (" Square Wave ");
    Serial.println (sqwe, HEX);

  }
}

Oh man I'm so sorry, I wanted to do it by myself, but I´m pretty slow to build codes!

Well, I needed it myself also so I could test from both serial ports on my board.
You weren't giving me very good confidence that the changes I was suggesting were actually correct, so I had to see.
Am helping 2 others with the same.
Apparantly my use of Serial1 vs Serial, and then a different program with more features than Arduino Serial Monitor has lent itself to much confusion all around.

Your task can be to add the extra 'C' and 'E' commands I didn't write to read back indivual registers and the 56 bytes of battery backed RAM.

Ok I'll try it, THANKS A LOT !

Excuse me, What are the conditions for read back a register?

I am not 100% sure. That sketch was my first time getting back over I2C, I got parts of it from the playground.

So, I think this might work:

   // Reset the register pointer  
    Wire.beginTransmission(RTC_address); 
    Wire.send(0x00);     <<< put in the address you want, 0x00 to 0x07
    Wire.endTransmission();   

    Wire.requestFrom(RTC_address,1);  
    register_contents = Wire.receive();

altho one would think the two could be combined somehow, the way writing a single register is done:

    Wire.requestFrom(RTC_address);  // send I2C address
>> send the register to read from - not sure what would be used here tho  
    register_contents = Wire.receive();   // read the data here

Hi, sorry but this is ok? I'm not sure if the square wave register reads that way! Normally we can access the F register, but if do we want to access to E register? I tried using else after the if (Serial.available() >3) with only the command and register data, but it didn´t work !

if ((incomingCommand == 'E') | (incomingCommand == 'e')){
  incomingCommand = 0;  // reset for next pass
//    RTC_register = incomingCommand & 0x0F;  // mask off low btye
//    incomingCommand = 0;
//    new_data = incomingData;
    Serial.println (" Sending Command ");
//    switch (RTC_register){
switch (incomingRegister){
  case '0': // read seconds
      Serial.println ("Seconds: ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(seconds_address);          // queue the register
      Wire.endTransmission();            // send it
      Wire.requestFrom(RTC_address,1);   // (device address, R/W) R=1, W=0
      seconds = Wire.receive();          // read the data here
      Serial.println(seconds, HEX);      
      delay (delay_time);
      break;
    case '1': // read minutes
      Serial.println ("Minutes: ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(minutes_address);          // queue the register
      Wire.endTransmission();             //  send it
      Wire.requestFrom(RTC_address,1);    //  read the data here 
      minutes = Wire.receive();
      Serial.println(minutes, HEX); 
      delay (delay_time);
      break;
   case '2': // read hours
      Serial.println ("Hours: ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(hours_address);          // queue the register
      Wire.endTransmission();            // send it
      Wire.requestFrom(RTC_address,1);   // read the data here
      hours = Wire.receive();
      Serial.println(hours, HEX); 
     delay (delay_time);
      break;
  case '3': // read day
      Serial.println ("Day: ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(day_week_address);          // queue the register
      Wire.endTransmission();            // send it
      Wire.requestFrom(RTC_address,1);   // (device address, R/W) R=1, W=0
      day_week = Wire.receive();         // read the data here
      Serial.println(day_week, HEX);      
      delay (delay_time);
      break;
  case '4': // read date of month
        Serial.println ("Day of Month: ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(date_month_address);          // queue the register
      Wire.endTransmission();            // send it
      Wire.requestFrom(RTC_address,1);   // (device address, R/W) R=1, W=0
      date_month = Wire.receive();       // read the data here
      Serial.println(date_month, HEX);      
      delay (delay_time);
      break;
  case '5': // read month
      Serial.println ("Month: ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(month_address);          // queue the register
      Wire.endTransmission();            // send it
      Wire.requestFrom(RTC_address,1);   // (device address, R/W) R=1, W=0
      month = Wire.receive();            // read the data here
      Serial.println(month, HEX);      
      delay (delay_time);
      break;
  case '6': // read year
      Serial.println ("Year: ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(year_address);          // queue the register
      Wire.endTransmission();            // send it
      Wire.requestFrom(RTC_address,1);   // (device address, R/W) R=1, W=0
      year = Wire.receive();             // read the data here

      Serial.println(year, HEX);      
      delay (delay_time);
      break;
  case '7': // read square wave
      Serial.println ("Square Wave: ");
      Serial.println (RTC_register, HEX);
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(square_address);          // queue the register
      Wire.endTransmission();            // send it
      Wire.requestFrom(RTC_address,1);   // (device address, R/W) R=1, W=0
      sqwe = Wire.receive();             // read the data here
      Serial.println(sqwe, HEX);      
     delay (delay_time);
      break;
  case '8': // read RAM
      Serial.print ("RAM ");
      Serial.println (RTC_register, HEX);
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(RTC_ram_address);          // queue the register
      Wire.endTransmission();            // send it
      Wire.requestFrom(RTC_address,1);   // (device address, R/W) R=1, W=0
      delay (delay_time);
      break;
      // all others,do nothing
      Serial.println ("Invalid command ");
     }  // end Switch
  } // end if command == 'E'
  // ************************************

Looks good halejandro! I would suggest changes at the start of void loop like this:
(and I took out some of old stuff)

void loop() {

  if (Serial.available() >3){
    incomingCommand = Serial.read();
    incomingRegister = Serial.read();
    incomingData1 = Serial.read();
    incomingData1 = incomingData1 - 0x30; // convert ASCII to HEX
    incomingData2 = Serial.read();
    incomingData2 = incomingData2 - 0x30;  // convert ASCII to HEX
    new_data = (incomingData1 << 4) + incomingData2;  // put the Upper/Lower nibbles together
    Serial.print ("command ");
    Serial.println (incomingCommand);
    Serial.print ("register ");
    Serial.println(incomingRegister);
    Serial.print ("data1 ");
    Serial.println (incomingData1, HEX);
    Serial.print ("data2 ");
    Serial.println (incomingData2, HEX);
    Serial.print ("combined data ");    
    Serial.println (new_data, HEX);
    
  }
  // *******************************************
if ((incomingCommand == 'F') | (incomingCommand == 'f')){incomingCommand = 'F');
if ((incomingCommand == 'E') | (incomingCommand == 'e')){incomingCommand = 'E');
if ((incomingCommand == 'C') | (incomingCommand == 'c')){incomingCommand = 'C'); // or whatever you decide to go with 

switch (incomingCommand) {
case 'F':
   switch (RTC_register){
   case '0':   /// and all the stuff from the original
:
:
case '8':
:
:
break;
// move this here now:

  incomingCommand = 0;  // reset for next pass
}  // end switch:case RTC_register for command 'F
break;  // end command 'F'

// Now add the next command
case 'E':
   switch (RTC_register){
   case '0':   /// and all the stuff you just wrote
:
:
case '8':
:
:
break;
// move this here now:

  incomingCommand = 0;  // reset for next pass
}  // end switch:case RTC_register for command 'E'
break;  // end command 'E'
//repeat for 'C'
Case 'C':
// etc.
break; //end command 'C'
  incomingCommand = 0;  // reset for next pass
} // end switch:case incomingCommand

So now you'll have a switch:case within a switch:case!

Please do a CTRL-T when you make the changes, will help check that the { and } are all paired up.

Ok, I made the changes, but I have a problem I can´t access to any function, I tested several ways but they didn´t work! the code is to big where can I send it to you?

Post it here - just take out
case 1:
:
:
case 7:

for the 'E' and 'F' commands to shorten it up, paste them back in after getting just case '0' working.

/*
Test of RTC DS1307 via I2C.
 Counts 
 Seconds, 
 Minutes, 
 Hours, 
 Date of the Month, 
 Month, 
 Day of the week, and 
 Year with Leap-Year
 
 56 bytes battery backed RAM
 Square Wave Output, can connect to INT2/D6 or PD7
 */

/*
Modified to Run thru IDE Serial port
 */
#include <Wire.h>

//variables
byte seconds_address = 0x00;
byte seconds; // bit 7 = Clock Halt, Enabled = 0, Halt = 1
// bits 6-5-3 = tens of seconds 0-6,  bits 3-2-1-0 = units of seconds, 0-9

byte minutes_address = 0x01;
byte minutes;  // bits 6-5-4 = tens of minutes, bits 3-2-1-0 = units of minutes

byte hours_address = 0x02; 
byte hours;  // 7=0. 6 = 1 for 12 hr, 0 for 24 hr.
// bit 5: 12 hr mode = AM(0)/PM(1). 24 hr mode = upper tens of hrs
// bit 4 =  lower tens of hrs, bits 3-2-1-0 = units of hours (0-9)

byte day_week_address = 0x03; 
byte day_week = 0; // range 01-07

byte date_month_address = 0x04;
byte date_month = 0; // range 01-31

byte month_address = 0x05;
byte month = 0; // range 01-12

byte year_address = 0x06;
int year = 0; // upper byte 0-9, lower byte 0-9

byte square_address = 0x07;
byte sqwe = 0;  // square wave enable
// Out-0-0-Sqwe-0-0-RS1-RS0
// Out, Sqwe = 0/0 - Square wave output = 0
// Out, Sqwe = 1/0 - Square wave output = 1
// Out, Sqwe = 0/1 or 1/1 - Square wave output per RS1/RS0
// RS1/RS0 = 00 = 1 Hz
// RS1/RSo = 01 = 4 KHz
// RS1/RS0 = 10 = 8 KHz
// RS1/RS0 = 11 = 32 KHz

byte RTC_ram_address = 0x08; //range = 08-63, 0x08-0x3F

int RTC_address = 0x68; // 1101 000 

byte incomingCommand = 0;
byte RTC_write_command = 0;
byte RTC_read_command = 0;
byte RTC_ram_command = 0;

// use F0xx, F1xx,F2xx, F3xx, F4xx, F5xx, F6xx, F7xx
// to send one register write commands
// use E0xx to read registers back - not coded yet
// use C0xx to read RAM back - not coded yet

byte incomingRegister = 0;
byte RTC_register = 0;
byte incomingData1 = 0;
byte incomingData2 = 0;
byte new_data = 0;
byte outgoingData = 0;
int delay_time = 100;

unsigned long currentMillis = 0;
unsigned long previousMillis = 0;
unsigned long duration = 5000;

void setup() {
  Wire.begin(); // no address, we are master
  Serial.begin (57600);  
  Serial.flush();
  currentMillis = millis();  
}

void loop() {

  if (Serial.available() >3){
    incomingCommand = Serial.read();
    incomingRegister = Serial.read();
    incomingData1 = Serial.read();
    incomingData1 = incomingData1 - 0x30; // convert ASCII to HEX
    incomingData2 = Serial.read();
    incomingData2 = incomingData2 - 0x30;  // convert ASCII to HEX
    new_data = (incomingData1 << 4) + incomingData2;  // put the Upper/Lower nibbles together
    Serial.print ("command ");
    Serial.println (incomingCommand);
    Serial.print ("register ");
    Serial.println(incomingRegister);
    Serial.print ("data1 ");
    Serial.println (incomingData1, HEX);
    Serial.print ("data2 ");
    Serial.println (incomingData2, HEX);
    Serial.print ("combined data ");    
    Serial.println (new_data, HEX);

  }
  // *******************************************
  if ((incomingCommand == 'F') | (incomingCommand == 'f')){
    incomingCommand = 'F';
    if ((incomingCommand == 'E') | (incomingCommand == 'e')){
      incomingCommand = 'E';  // or whatever you decide to go with 

      switch (incomingCommand) {        
      case 'F': 
        Serial.println (" Sending a command ");
        switch (incomingRegister){
        case '0': // write seconds
          Serial.println ("Seconds ");
          Wire.beginTransmission(RTC_address); // select device
          Wire.send(seconds_address);          // queue the register
          Wire.send(new_data);                  // queue data
          Wire.endTransmission();            // send it
          delay (delay_time);
          break;
        case '8': // write RAM
          Serial.print ("RAM ");
          Serial.println (RTC_register, HEX);
          Wire.beginTransmission(RTC_address); // select device
          Wire.send(RTC_ram_address);          // queue the register
          Wire.send(new_data);                  // queue data
          Wire.endTransmission();            // send it
          delay (delay_time);
          break;
          incomingCommand = 0;  // reset for next pass
        }  // end switch:case RTC_register for command 'F
        break;  // end command 'F'
      case 'E':
        switch (incomingRegister){ 
          Serial.println (" Sending Command ");  
        case '0': // read seconds
          Serial.println ("Seconds: ");
          Wire.beginTransmission(RTC_address); // select device
          Wire.send(seconds_address);          // queue the register
          Wire.endTransmission();            // send it
          Wire.requestFrom(RTC_address,1);   // (device address, R/W) R=1, W=0
          seconds = Wire.receive();          // read the data here
          Serial.println(seconds, HEX);      
          delay (delay_time);
          break;
        case '8': // read RAM
          Serial.print ("RAM ");
          Serial.println (RTC_register, HEX);
          Wire.beginTransmission(RTC_address); // select device
          Wire.send(RTC_ram_address);          // queue the register
          Wire.endTransmission();            // send it
          Wire.requestFrom(RTC_address,1);   // (device address, R/W) R=1, W=0
          delay (delay_time);
          break;
          incomingCommand = 0;  // reset for next pass
        }  // end switch:case RTC_register for command 'E'
        break;  // end command 'E'  
      }
    }
  }     


  // ************************************

  currentMillis = millis();
  if ( (currentMillis - previousMillis) >= duration){
    previousMillis = currentMillis;  
    // Reset the register pointer  
    Wire.beginTransmission(RTC_address);  
    Wire.send(0x00);  
    Wire.endTransmission();   

    Wire.requestFrom(RTC_address,8 );  
    seconds = Wire.receive();  
    minutes = Wire.receive();  
    hours = Wire.receive();  
    day_week = Wire.receive();  
    date_month = Wire.receive();  
    month = Wire.receive();  
    year = Wire.receive();  
    sqwe = Wire.receive();

    // Seconds 
    // bit 7 = Clock Halt, Enabled = 0, Halt = 1
    // bits 6-5-3 = tens of seconds 0-6,  bits 3-2-1-0 = units of seconds, 0-9 

    // Hours
    // 7=0. 6 = 1 for 12 hr, 0 for 24 hr.
    // bit 5: 12 hr mode = AM(0)/PM(1). 24 hr mode = upper tens of hrs
    // bit 4 =  lower tens of hrs, bits 3-2-1-0 = units of hours (0-9)

    Serial.print ("Hrs " );
    Serial.print (hours, HEX);
    Serial.print (" Mins ");
    Serial.print (minutes, HEX);
    Serial.print (" Secs ");
    Serial.print (seconds, HEX);
    Serial.print (" Day ");
    Serial.print (day_week, HEX);
    Serial.print (" Date ");
    Serial.print (date_month, HEX);
    Serial.print (" Month ");
    Serial.print (month, HEX);
    Serial.print (" Year 20");
    Serial.print (year, HEX);
    Serial.print (" Square Wave ");
    Serial.println (sqwe, HEX);
  }
}

Try this. I think the problem was not quite correct usage of { & }.

/*
Test of RTC DS1307 via I2C.
 Counts 
 Seconds, 
 Minutes, 
 Hours, 
 Date of the Month, 
 Month, 
 Day of the week, and 
 Year with Leap-Year
 
 56 bytes battery backed RAM
 Square Wave Output, can connect to INT2/D6 or PD7
 */

/*
Modified to Run thru IDE Serial port
 */
#include <Wire.h>

//variables
byte seconds_address = 0x00;
byte seconds; // bit 7 = Clock Halt, Enabled = 0, Halt = 1
// bits 6-5-3 = tens of seconds 0-6,  bits 3-2-1-0 = units of seconds, 0-9

byte minutes_address = 0x01;
byte minutes;  // bits 6-5-4 = tens of minutes, bits 3-2-1-0 = units of minutes

byte hours_address = 0x02; 
byte hours;  // 7=0. 6 = 1 for 12 hr, 0 for 24 hr.
// bit 5: 12 hr mode = AM(0)/PM(1). 24 hr mode = upper tens of hrs
// bit 4 =  lower tens of hrs, bits 3-2-1-0 = units of hours (0-9)

byte day_week_address = 0x03; 
byte day_week = 0; // range 01-07

byte date_month_address = 0x04;
byte date_month = 0; // range 01-31

byte month_address = 0x05;
byte month = 0; // range 01-12

byte year_address = 0x06;
int year = 0; // upper byte 0-9, lower byte 0-9

byte square_address = 0x07;
byte sqwe = 0;  // square wave enable
// Out-0-0-Sqwe-0-0-RS1-RS0
// Out, Sqwe = 0/0 - Square wave output = 0
// Out, Sqwe = 1/0 - Square wave output = 1
// Out, Sqwe = 0/1 or 1/1 - Square wave output per RS1/RS0
// RS1/RS0 = 00 = 1 Hz
// RS1/RSo = 01 = 4 KHz
// RS1/RS0 = 10 = 8 KHz
// RS1/RS0 = 11 = 32 KHz

byte RTC_ram_address = 0x08; //range = 08-63, 0x08-0x3F

int RTC_address = 0x68; // 1101 000 

byte incomingCommand = 0;
byte RTC_write_command = 0;
byte RTC_read_command = 0;
byte RTC_ram_command = 0;

// use F0xx, F1xx,F2xx, F3xx, F4xx, F5xx, F6xx, F7xx
// to send one register write commands
// use E0xx to read registers back - not coded yet
// use C0xx to read RAM back - not coded yet

byte incomingRegister = 0;
byte RTC_register = 0;
byte incomingData1 = 0;
byte incomingData2 = 0;
byte new_data = 0;
byte outgoingData = 0;
int delay_time = 100;

unsigned long currentMillis = 0;
unsigned long previousMillis = 0;
unsigned long duration = 5000;

void setup() {
  Wire.begin(); // no address, we are master
  Serial.begin (57600);  
  Serial.flush();
  currentMillis = millis();  
}

void loop() {

  if (Serial.available() >3){
    incomingCommand = Serial.read();
    incomingRegister = Serial.read();
    incomingData1 = Serial.read();
    incomingData1 = incomingData1 - 0x30; // convert ASCII to HEX
    incomingData2 = Serial.read();
    incomingData2 = incomingData2 - 0x30;  // convert ASCII to HEX
    new_data = (incomingData1 << 4) + incomingData2;  // put the Upper/Lower nibbles together
    Serial.print ("command ");
    Serial.println (incomingCommand);
    Serial.print ("register ");
    Serial.println(incomingRegister);
    Serial.print ("data1 ");
    Serial.println (incomingData1, HEX);
    Serial.print ("data2 ");
    Serial.println (incomingData2, HEX);
    Serial.print ("combined data ");    
    Serial.println (new_data, HEX);

  }
  // *******************************************
  if ((incomingCommand == 'F') | (incomingCommand == 'f')){
    incomingCommand = 'F';
  }
  if ((incomingCommand == 'E') | (incomingCommand == 'e')){
    incomingCommand = 'E';  // or whatever you decide to go with 
  }

  switch (incomingCommand) {        
  case 'F': 
    Serial.println (" Sending a command ");
    switch (incomingRegister){
    case '0': // write seconds
      Serial.println ("Seconds ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(seconds_address);          // queue the register
      Wire.send(new_data);                  // queue data
      Wire.endTransmission();            // send it
      delay (delay_time);
      break;
    case '8': // write RAM
      Serial.print ("RAM ");
      Serial.println (RTC_register, HEX);
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(RTC_ram_address);          // queue the register
      Wire.send(new_data);                  // queue data
      Wire.endTransmission();            // send it
      delay (delay_time);
      break;
      incomingCommand = 0;  // reset for next pass
    }  // end switch:case RTC_register for command 'F
    break;  // end command 'F'
  case 'E':
    switch (incomingRegister){ 
      Serial.println (" Sending Command ");  
    case '0': // read seconds
      Serial.println ("Seconds: ");
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(seconds_address);          // queue the register
      Wire.endTransmission();            // send it
      Wire.requestFrom(RTC_address,1);   // (device address, R/W) R=1, W=0
      seconds = Wire.receive();          // read the data here
      Serial.println(seconds, HEX);      
      delay (delay_time);
      break;
    case '8': // read RAM
      Serial.print ("RAM ");
      Serial.println (RTC_register, HEX);
      Wire.beginTransmission(RTC_address); // select device
      Wire.send(RTC_ram_address);          // queue the register
      Wire.endTransmission();            // send it
      Wire.requestFrom(RTC_address,1);   // (device address, R/W) R=1, W=0
      delay (delay_time);
      break;
      incomingCommand = 0;  // reset for next pass
    }  // end switch:case RTC_register for command 'E'
    break;  // end command 'E'  
  }




  // ************************************

  currentMillis = millis();
  if ( (currentMillis - previousMillis) >= duration){
    previousMillis = currentMillis;  
    // Reset the register pointer  
    Wire.beginTransmission(RTC_address);  
    Wire.send(0x00);  
    Wire.endTransmission();   

    Wire.requestFrom(RTC_address,8 );  
    seconds = Wire.receive();  
    minutes = Wire.receive();  
    hours = Wire.receive();  
    day_week = Wire.receive();  
    date_month = Wire.receive();  
    month = Wire.receive();  
    year = Wire.receive();  
    sqwe = Wire.receive();

    // Seconds 
    // bit 7 = Clock Halt, Enabled = 0, Halt = 1
    // bits 6-5-3 = tens of seconds 0-6,  bits 3-2-1-0 = units of seconds, 0-9 

    // Hours
    // 7=0. 6 = 1 for 12 hr, 0 for 24 hr.
    // bit 5: 12 hr mode = AM(0)/PM(1). 24 hr mode = upper tens of hrs
    // bit 4 =  lower tens of hrs, bits 3-2-1-0 = units of hours (0-9)

    Serial.print ("Hrs " );
    Serial.print (hours, HEX);
    Serial.print (" Mins ");
    Serial.print (minutes, HEX);
    Serial.print (" Secs ");
    Serial.print (seconds, HEX);
    Serial.print (" Day ");
    Serial.print (day_week, HEX);
    Serial.print (" Date ");
    Serial.print (date_month, HEX);
    Serial.print (" Month ");
    Serial.print (month, HEX);
    Serial.print (" Year 20");
    Serial.print (year, HEX);
    Serial.print (" Square Wave ");
    Serial.println (sqwe, HEX);
  }
}

What are the conditions to read and write in RAM?

Read & write to 0x08 up to 0x3F.
Or decimal 08 to 63.
Follow the same steps as the others to access 1 byte, 8 bytes, etc. up to 56 bytes.