Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

DS1307 and 24LC256 wont work together
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

DS1307 and 24LC256 wont work together

by Volkemon on Mon Jul 26, 2010 4:24 pm

Hi!

Just started messing around with the 24LC256 32kB memory chip. I integrated it into a sketch I have that has the wire library already in it, and a DS1307 Real Time Clock.

But in the void loop(void) where the RTC is called, I cannot do any successful Wire.send commands to the 24LC256. Even after properly addressing it, etc. Is there something in the RTC library that stops them both from being used?

Or maybe when I type Wire.send(now.hour()); This brings the DS1307 active on the bus, and the 24LC256 is booted off...
Livin' , learnin' , lovin' and laffin'. Thanks for the help!
Image
User avatar
Volkemon
 
Posts: 127
Joined: Mon May 10, 2010 8:24 pm
Location: Melbourne FL USA

Re: DS1307 and 24LC256 wont work together

by adafruit on Mon Jul 26, 2010 9:27 pm

we suggest reading the entirety of the RTC library and making sure you understand how i2c is addressed and spoken to in arduino land

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: DS1307 and 24LC256 wont work together

by chuckm on Tue Jul 27, 2010 12:22 pm

I don't believe the i2c library on the Arduino will let you do this. One of the problems is that the 24LC256 uses double byte addressing whereas the Arduino library is assuming single byte addressing. And there is the issue that I don't recall that the Arduino library had write support at all but I may be mis remembering on that score.

To your second question, if you have multiple devices you are pretty much stuck with selecting and addressing your devices each time. For the '256 that means sending the sequence "SLA+W, High byte, low byte, SLA+R, read a byte" or for writing "SLA+W, high byte, low byte, write byte".

--Chuck

chuckm
 
Posts: 159
Joined: Thu Dec 24, 2009 3:31 am

Re: DS1307 and 24LC256 wont work together

by Volkemon on Sat Jul 31, 2010 11:38 am

@adafruit - "we suggest reading the entirety of the RTC library " ok! :)

This has been my source for information on libraries, and I see no RTC library mentioned. http://arduino.cc/en/Reference/Libraries

Any other sources I should be using? Thanks!

@ChuckM - I am using the correct format, I think: (snippet)

Code: Select all | TOGGLE FULL SIZE
      Wire.beginTransmission(chipAdress);    // chipAdress = chip address on the TWI bus, not chip memory address. Starts loading buffer for 24LC256
      startaddrMSB = highByte(startAddress);  // takes the MSB off the memory address, first 7 bits
      startaddrLSB = lowByte(startAddress);   // takes the LSB off the memory location, second 8 bits
      Wire.send(startaddrMSB);      //First  7 bits of the address (Byte1)
      Wire.send(startaddrLSB);     //Second 8 bits of the address(Byte2) Internal Address Pointer is now ready to read/write at our desired location

(The 'Byte 1,2' is for keeping count of how many Bytes are in the buffer, waiting to be sent to the 24LC256. It can only hold 32 total before a
'Wire.endTransmission();' is sent, actually writing the data to the 24LC256.)

I am hoping that arduwino is pointing me at the source for an answer to this.

I have it working for now by saving the values for the RTC:" byte rtch = (now.hour()); // stores hour value for 24LC256 use" etc.

and using them in the other part of the sketch where the 24LC256 does not compete with the DS1307.

Late reply is because I forgot to check the 'notify me' box... checked now! ;)
Livin' , learnin' , lovin' and laffin'. Thanks for the help!
Image
User avatar
Volkemon
 
Posts: 127
Joined: Mon May 10, 2010 8:24 pm
Location: Melbourne FL USA

Re: DS1307 and 24LC256 wont work together

by Volkemon on Sun Aug 01, 2010 12:41 am

Learning how to address the 24LC256, and reading the DS1307 datasheet with 'new eyes' this might be easy!

http://pdfserv.maxim-ic.com/en/ds/DS1307.pdf

Table 2 on page 8 outlines all I need. (I think...) I should be able to read (or write) values for time and date on the DS1307 using just the Wire library, and have no need for the RTC library. Hopefully this will remove the conflict.

To set the month to July, for example:

Code: Select all | TOGGLE FULL SIZE
Wire.beginTransmission(0x68); // bus address of DS1307
Wire.send(0x05);  // sets register pointer to 'months'
Wire.send(0x07);  // sets months to 7, or July
Wire.endTransmission(); //  writes value to chip


To read, set the register pointer to (0x00) then do a 'Wire.requestFrom(chipAdress, 7);' and parse the data recieved. 'Then Wire.endTransmission'

Maybe the RTC library never gives the 'Wire.endTransmission' command, and that keeps the bus busy so the 24LC256 cant get on :)
Livin' , learnin' , lovin' and laffin'. Thanks for the help!
Image
User avatar
Volkemon
 
Posts: 127
Joined: Mon May 10, 2010 8:24 pm
Location: Melbourne FL USA

Re: DS1307 and 24LC256 wont work together

by adafruit on Sun Aug 01, 2010 1:05 am

we do suggest reading the RTC library code - that way you can see exactly whats going on :)

its in your arduino library - right where you installed it

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: DS1307 and 24LC256 wont work together

by Volkemon on Sun Aug 01, 2010 1:25 am

**BING**

Yep. Sometimes it is just the right clue...

I had been opening the RTClib.h and RTClib.ccp using the default 'notepad'. This resulted in (to me..) gibberish.

Change that to "Wordpad" and *WOW*... there is familiar code!

I see I have a few hours of study!

*THANKS*
Livin' , learnin' , lovin' and laffin'. Thanks for the help!
Image
User avatar
Volkemon
 
Posts: 127
Joined: Mon May 10, 2010 8:24 pm
Location: Melbourne FL USA

Re: DS1307 and 24LC256 wont work together

by Volkemon on Mon Aug 16, 2010 1:36 pm

Hm. Reading the libraries did not help due to my level of understanding at this time being to low. :?

What I did was to set up (3) 'byte' variables named rtch,rtcm and rtcs. In the 'void loop()' , where I call the RTC, I assign the time values to the variables. Then in the section I call the 24LC256, 'void readpacket()' , I 'Wire.send' them. The sketch is HUGE, but I can post snippets if needed.
Livin' , learnin' , lovin' and laffin'. Thanks for the help!
Image
User avatar
Volkemon
 
Posts: 127
Joined: Mon May 10, 2010 8:24 pm
Location: Melbourne FL USA

Re: DS1307 and 24LC256 wont work together

by pstemari on Tue Aug 24, 2010 2:26 am

I had been opening the RTClib.h and RTClib.ccp using the default 'notepad'. This resulted in (to me..) gibberish.


Line endings--Wordpad will recognized Unix LF endings and DOS/Windows CRLF endings. Notepad ignores the lone LF's.
--Paul

A wholly owned subsidiary of:
Persephone: DL R+W+B C 7 X L W C++ I++ T+ A E H++ S+ V-- F+ Q P B PA+ PL
Aldebaran: DM Rt H 5 Y L- W+ C+ I++ T++ A+++ E H++ S+ V+ F++ Q+ P B++ PA- PL--
User avatar
pstemari
 
Posts: 310
Joined: Sun Mar 21, 2010 6:10 pm
Location: Seattle, WA

Please be positive and constructive with your questions and comments.