ds1307 i2c


Closed Thread
Results 1 to 7 of 7

Thread: ds1307 i2c

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tamertokgoz View Post
    Hii.

    I wanna ask a question :

    How can I stop reading from ds1307 and start writing to eeprom on the same sda scl line and after writing start reading from ds1307 again
    This looks like interrupt based operation of DS1307 to read the RTC. You cannot do this. What you can do is set a bit variable while you are reading the rtc and use this to avoid writing to the eeprom.

  2. #2
    Join Date
    May 2008
    Posts
    10


    Did you find this post helpful? Yes | No

    Default not interrupt based

    Quote Originally Posted by Jerson View Post
    This looks like interrupt based operation of DS1307 to read the RTC. You cannot do this. What you can do is set a bit variable while you are reading the rtc and use this to avoid writing to the eeprom.
    the program was written : for to measure frequency and amper and if it is greater then desired value write it to the eeprom. it will be a logger

  3. #3
    Join Date
    May 2008
    Posts
    10


    Did you find this post helpful? Yes | No

    Exclamation it is not working also

    Code:
    ADD VAR WORD
    ADDO VAR WORD
    FX VAR WORD
    
    
    sec  var byte
    mnt  var byte
    hour var byte
    day var byte
    month var byte
    year var byte
    
    BOOT:
                LCDOut $fe, 1              
                
                LCDOut "          "
     
                LCDOut $fe,$c0," "
    			pause 1000
    			ADD =10
    
    
     
           
    LOOP:        
         
           i2cread  SDA,scl,$D0,0,[sec,mnt,hour,day,month]
    
        pause 225 
    
               LCDOut $fe, 1              
               Lcdout hex2(hour),hex2(mnt),hex2(Sec), "-", hex2(day),".", hex2(month),"."
     
               LCDOut $fe,$c0,"Okudum Yazcam"
               
               ADD = ADD +1 
               I2CWRITE SDA,SCL,$A0,ADD,[ADD]',BOGUS
               PAUSE 250    
               
           IF BTN1 THEN OKU      
    	GoTo loop					' Do it forever	
    OKU : 
       FOR ADDO =10 TO ADD
            I2CREAD SDA,SCL,$A0,ADDO,[FX]',BOGUS2
                PAUSE 25
            SEROUT2  So,84,[DEC ADDO ,"--", DEC(FX), 13,10]
                PAUSE 50
                
        NEXT
    GOTO LOOP
    bogus:
    		LCDOut $fe,1, "wrt timed out"	' I2C command timed out
    		Pause 100
            RETURN               
    
    bogus2:
    		LCDOut $fe,1, "read timed out"	' I2C command timed out
    		Pause 100
            RETURN               
                    
    End

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    Your program is writing continuously to the eeprom. Totally unadvisable. If you have to do it this way, at least slow it down to around 1 write every minute. The interrupt operation I was suspecting is ruled out after seeing your code. I feel your frequent writes may have damaged the eeprom by now.

Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  2. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  3. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  4. I2C eeprom and DS1307 @40MHz problem
    By ius01 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 20th July 2007, 07:41
  5. Please help with i2cslave i2c slave
    By cycle_girl in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st December 2005, 13:55

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts