DS3231 works in one config, but does not works with other IC.


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default DS3231 works in one config, but does not works with other IC.

    Here I had a nice thread about DIY nixie clock, which is now gone. It was using DS1302 RTC, and many people asked to upgrade it to more precise DS3231. So I've bought one.

    I took the code for DS1307 from here: http://melabs.com/samples/LABXUSB-18F4550/rtcxu.htm and slightly modified it to run on 16F886 (changed LCD pins and other config info). It works just fine, time can be set and read with great precision. So I decided to move the code to my nixie clock code, which runs on 16F1519. And now strange things happen. No matter what I write to DS3231, it returns "20-20-20" for time-hour-seconds. My complete code is quite long, so I'll post short fragment relating this chip. It is not wiring issue, because if I remove the DS3231, it will return 000000 as it should.

    Code:
    include "modedefs.bas"
    OSCCON = %01110010  'SET INTOSC TO 8MHZ
    ANSELC=%00000000
    ANSELD=%00000000 'disable ADC
    ANSELB=%00000000
    ANSELA=%00000000
    ANSELE=%00000000
    TRISC=%00000000 'set PORTC as output all
    TRISD=%00000000 'set PORTD as output all
    TRISB=%00000000 'set PORTD as output all
    TRISA=%00000110 'tried to make 4-5 pins inputs or outputs, no difference
    TRISE=%00000000
    DEFINE OSC 8   'OSC SPEED
    
    SDA Var PORTA.5 'DS 3231 pins
    SCL Var PORTA.4
    
    RTCYear  Var Byte
    RTCMonth Var Byte
    RTCDate  Var Byte
    RTCDay   Var Byte
    RTCHour  Var Byte
    RTCMin   Var Byte
    RTCSec   Var Byte
    RTCCtrl  Var Byte 
    
    settime:
    'rtcsec=0 ' this is necessary to make clock tick
       I2CWrite SDA, SCL, $D0, $00, [RTCSec, RTCMin, RTCHour, RTCDay, RTCDate, RTCMonth, RTCYear, RTCCtrl]
       Return
    
    gettime:
       I2CRead SDA, SCL, $D0, $00, [RTCSec, RTCMin, RTCHour, RTCDay, RTCDate, RTCMonth, RTCYear, RTCCtrl]
       Return
       
       if DRO<>rtcmin then  'check for time changes, so display only is refreshed when time is changed
       cvlileba=1
       else
       cvlileba=0
       endif 
     
     DRO=rtcmin 
       Return  
    
    timedecode:       'decode time from RTC into values suitable for nixie digit illumination
       t1=rtchour >> 4   'tens of hours digits
       t2=rtchour // 16   'ones of hours
       t3=rtcMin >> 4     'tens of minutes
       T4=rtcMin // 16    'ones of minutes
       
     
    return
    
    


    So no matter what I set or red, always T1 and T3=2 and T2 and T4 =0. But I've added a cvlileba variable, to monitor whenever clock is "ticking" so it is indeed ticking, because this variable keeps changing each minute. So what is wrong, my decoding routine?





  2. #2
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: DS3231 works in one config, but does not works with other IC.

    Fixed it - was caused by wiring issue. I did an error - ordered black PCB's, and traces are very hard to see there, so I've soldered to PORTE.0 instead of PORTA.5

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    Did you find this post helpful? Yes | No

    Default Re: DS3231 works in one config, but does not works with other IC.

    Black is nice but as you said hard to spot errors.

    Ioannis

  4. #4
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: DS3231 works in one config, but does not works with other IC.

    Yes, so I took sandpaper and removed all the masking paint

Similar Threads

  1. WRITECODE - How it works
    By Ioannis in forum PBP3
    Replies: 4
    Last Post: - 17th June 2015, 14:45
  2. HSERIN almost works, but need help...
    By thasatelliteguy in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th June 2014, 17:27
  3. I can't beleive this works! :D
    By Art in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th October 2013, 08:00
  4. How On Interrupt works?
    By koossa in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 22nd February 2008, 14:50
  5. Only (1) DEBUG works
    By droptail in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 14th March 2006, 05:52

Members who have read this thread : 1

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