Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with DS1307 RTC

Status
Not open for further replies.

Eddd

Newbie level 3
Joined
Oct 22, 2014
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
31
I have strange problem with DS1307 Real Time Clock. It is custom made PCB which contains Atmel ATmega 2560. When I run I2C scan test program to list all the devices on the I2C, I can't find DS1307 (which it should be at address 0x68), but other I2C devices are listed and work fine. But once I connect the battery, the whole I2C bus go down and nothing is listed. The schematics is shown below.

What do think the problem is?

RTC-Problem.png
 

Are you detecting devices using ACK bit ? What are the other devices and their addresses ?
 

Yes, I use Arduino IDE and libraries. The program loops from 1 to 128 and check returned value of Wire.endTransmission().

I get those addresses
0x20 PCA9555D (IO Expander)
0x38 PCF8574 (IO Expander)
0x48 ADS1115 (ADC)
0x49 ADS1115 (ADC)
0x50 EEPROM 64KB
0x51 EEPROM 64KB
two devices are missing
DS1307 RTC should be at 0x68
TC74A3-5.0VCT temperature sensor should be at 0x4B




Code:
  for(address = 1; address < 255; address++ ) 
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      cons1.print("I2C device found at address 0x");
      if (address<16) 
        cons1.print("0");
      cons1.print(address,HEX);
      cons1.println("  !");

      nDevices++;
    }
    else if (error==4) 
    {
      cons1.print("Unknow error at address 0x");
      if (address<16) 
        cons1.print("0");
      cons1.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    cons1.println("No I2C devices found\n");
  else
    cons1.println("done\n");
 

Does the function

Code C - [expand]
1
error = Wire.endTransmission();


is having stop I2C ?

What is the I2C bus frequency ?

Other than detection, RTC interface is working or not ?
 
  • Like
Reactions: Eddd

    Eddd

    Points: 2
    Helpful Answer Positive Rating
The documentation of Arduino says that the returned value is:

0:success
1:data too long to fit in transmit buffer
2:received NACK on transmit of address
3:received NACK on transmit of data
4:eek:ther error

The default I2C in Arduino is 100kHz.

I'm not sure how check if the RTC interface is working or not?

The strange thing is when I put the battery I get absolutely nothing in the list, it seems if the loop hangs because it doesn't even prints the "done" message. But, when the battery is removed, all other I2C devices work fine.
 

I think the problem is missing stop I2C signal.

Are able to read the time and date from RTC ?

Also there is a possibility of problem in read mode ? which continuously getting 0 from RTC. try sending the address send with write mode or vice versa.

- - - Updated - - -

Code C - [expand]
1
Wire.beginTransmission(address & 0xFE);



This will allow you to only run test on Write mode, so that slaves will not get control over the bus.
 

I tried your code and RTC is still missing :(

I can't read or write anything to the RTC. Furthermore, when I tried to add an external DS1307 module to the card using I2C it worked OK.

I think the problem is in the Hardware, but I can't figure out how to troubleshoot it! I had same circuit in older PCB and it is working fine. All what I did is changing the battery holder!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top