RTC chip or PIC?


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    952


    Did you find this post helpful? Yes | No

    Default Trigger the time (seconds) change

    Thanks mackrackit,

    My question was more about to understand how to trigger the time (seconds) change to start a display update or refresh.

    I was thinking about putting the PIC in low-power mode until the next second change happens; how to achieve this the best way?

    So is there any particular specification of RTC chips that will allow one to find a modell having, for example, a functionality setting a bit or a flag telling the second has changed?

    BTW, here is the code (multiple sources - thanks to All of them) I work on now for my tests:
    Code:
    <html><head></head><body><!--StartFragment--><pre><code><font color="#000080"><i>' PIC16F630 Fuses
    </i></font><font color="#008000">@ DEVICE BOD_OFF
    @ DEVICE CPD_OFF
    @ DEVICE PROTECT_OFF
    @ DEVICE MCLR_OFF
    @ DEVICE PWRT_OFF
    @ DEVICE WDT_OFF
    @ DEVICE INTRC_OSC_NOCLKOUT
    
    </font><font color="#000080"><i>'-------------------------------------------------------------------------------
    ' Registers   76543210
    </i></font>WPUA       = %00110000 <font color="#000080"><i>'Weak Pull-up of PORTA for SCL and SDA on DS1307
    </i></font>INTCON     = %00000000 <font color="#000080"><i>'Interrupts
    </i></font>OSCCAL     = %01100000 <font color="#000080"><i>'Oscillator Calibration when Internal RC set to 4MHz
    </i></font>OPTION_REG = %10000000 <font color="#000080"><i>'PORTA Pull-Ups/TMR0/Prescaler
    </i></font>CMCON      = %00000111 <font color="#000080"><i>'Comparator Module is OFF
    </i></font>TRISA      = %00000000 <font color="#000080"><i>'Set Input/Output
    </i></font>PORTA      = %00000000 <font color="#000080"><i>'Ports High/Low
    </i></font>TRISC      = %00000000 <font color="#000080"><i>'Set Input/Output
    </i></font>PORTC      = %00000000 <font color="#000080"><i>'Ports High/Low
    
    '-------------------------------------------------------------------------------
    'PORTA.0 = ICSP Data
    'PORTA.1 = ICSP Clock
    'PORTA.2
    'PORTA.3 = MCLR
    'PORTA.4 = SDA
    'PORTA.5 = SCL
    'PORTC.0 = LCD-DB4
    'PORTC.1 = LCD-DB5
    'PORTC.2 = LCD-DB6
    'PORTC.3 = LCD-DB7
    'PORTC.4 = LCD-E
    'PORTC.5 = LCD-RS
    
    '-------------------------------------------------------------------------------
    ' LCD cabling
    '-       ( 1) Vss - GND
    '-	 ( 2) Vdd / Vcc +5V
    '-	 ( 3) Vee / Vo / Contrast adjust / Pot 4k7(1-2-W3) or R2k2 (GND-3)
    'PORTC.5 ( 4) RS
    '-	 ( 5) R/W -&gt; to Vss
    'PORTC.4 ( 6) E
    'PORTC.0 (11) DB4
    'PORTC.1 (12) DB5
    'PORTC.2 (13) DB6
    'PORTC.3 (14) DB7
    
    </i></font><b>DEFINE </b>LCD_DREG PORTC   <font color="#000080"><i>'LCD data port 
    </i></font><b>DEFINE </b>LCD_DBIT 0       <font color="#000080"><i>'LCD data starting PORT.bit (0 or 4)
    </i></font><b>DEFINE </b>LCD_RSREG PORTC  <font color="#000080"><i>'LCD register select port 
    </i></font><b>DEFINE </b>LCD_RSBIT 5      <font color="#000080"><i>'LCD register select bit 
    </i></font><b>DEFINE </b>LCD_EREG PORTC   <font color="#000080"><i>'LCD enable port 
    </i></font><b>DEFINE </b>LCD_EBIT 4       <font color="#000080"><i>'LCD enable bit 
    
    '-------------------------------------------------------------------------------
    ' Variables
    </i></font>SDA      <b>VAR </b>PORTA.4 <font color="#000080"><i>'DS1307 SDA pin #5
    </i></font>SCL      <b>VAR </b>PORTA.5 <font color="#000080"><i>'DS1307 SCL pin #6
    'SDOut    var PORTC.2
    </i></font>DB       <b>VAR BYTE</b>[8] <font color="#000080"><i>'Data byte array
    </i></font>RTCSec   <b>VAR </b>DB[0]   <font color="#000080"><i>'alias individual bytes in array
    </i></font>RTCMin   <b>VAR </b>DB[1]
    RTCHour  <b>VAR </b>DB[2]
    RTCDay   <b>VAR </b>DB[3]
    RTCDate  <b>VAR </b>DB[4]
    RTCMonth <b>VAR </b>DB[5]
    RTCYear  <b>VAR </b>DB[6]
    RTCCtrl  <b>VAR </b>DB[7]
    AMPM     <b>VAR BIT
    </b>A_Ctr    <b>VAR BYTE    </b><font color="#000080"><i>'counter
    </i></font>B_Ctr    <b>VAR BYTE    </b><font color="#000080"><i>'counter
    </i></font>Day_T    <b>VAR BYTE
    </b>Day      <b>VAR BYTE</b>[3]
    Day[0] = 0
    Day[1] = 0
    Day[2] = 0
    
    <font color="#000080"><i>'-------------------------------------------------------------------------------
    </i></font><b>PAUSE </b>1000        <font color="#000080"><i>'time for LCD to settle
    </i></font><b>LCDOUT </b>$FE, 1     <font color="#000080"><i>'Clear LCD
    </i></font><b>GOSUB </b>WRITE_1307  <font color="#000080"><i>'set the time or don't
    
    </i></font>MAIN:
       <b>GOSUB </b>READ_1307 <font color="#000080"><i>'Read the time &amp; date
       </i></font><b>GOSUB </b>LCD
       <b>PAUSE </b>1000
    <b>GOTO </b>MAIN:
    
    <font color="#000080"><i>'-------------------------------------------------------------------------------
    </i></font>LCD:
    
    <font color="#000080"><i>'Hour in &quot;hh:mm:ss&quot;
    </i></font><b>LCDOUT </b>$FE, 2, <b>DEC </b>(RTCHour&gt;&gt;4 &amp; $0F), <b>DEC</b>(RTCHour &amp; $0F),<font color="#FF0000">&quot;:&quot;</font>, _
                   <b>DEC</b>((RTCMin&gt;&gt;4)&amp; $0F), <b>DEC</b>(RTCMin &amp; $0F),<font color="#FF0000">&quot;:&quot;</font>, _
                   <b>DEC</b>((RTCSec&gt;&gt;4)&amp; $0F), <b>DEC</b>(RTCSec &amp; $0F)
    <font color="#000080"><i>'Day
    </i></font>B_Ctr = 0
    <b>FOR </b>A_Ctr = (((RTCDay &amp; $07)-1)*3) <b>TO </b>(((RTCDay &amp; $07)-1)*3)+2
      <b>LOOKUP </b>A_Ctr,[<font color="#FF0000">&quot;SunMonTueWedThuFriSat&quot;</font>],Day_T
      Day[B_Ctr] = Day_T
      B_Ctr = B_Ctr + 1
    <b>NEXT </b>A_Ctr
    <b>LCDOUT </b>$FE, 2, $FE, $C0, Day[0], Day[1], Day[2]
    
    <font color="#000080"><i>'Date in &quot;mm-dd-yyyy&quot;
    </i></font><b>LCDOUT </b>$FE, $C4, <b>DEC</b>((RTCDate&gt;&gt;4)&amp; $03), <b>DEC</b>(RTCDate &amp; $0F),<font color="#FF0000">&quot;-&quot;</font>, _
                     <b>DEC</b>((RTCMonth&gt;&gt;4)&amp; $01), <b>DEC</b>(RTCMonth &amp; $0F),<font color="#FF0000">&quot;-&quot;</font>, _
                     <b>DEC</b>(((RTCYear&gt;&gt;4)&amp; $0F)*100),<b>DEC</b>(RTCYear &amp; $0F)
    
    <b>RETURN    
        
    </b><font color="#000080"><i>'-------------------------------------------------------------------------------    
    </i></font>READ_1307:
    <font color="#000080"><i>' Read order is in Secs,Mins,Hours,Day,Date,Month,Year,Control
    </i></font><b>I2CREAD </b>SDA,SCL,$D0,$00,[<b>STR </b>DB\8] <font color="#000080"><i>' Read string of 8 bytes from DS1307
    </i></font><b>RETURN
    
    </b><font color="#000080"><i>'-------------------------------------------------------------------------------
    </i></font>WRITE_1307:
    <font color="#000080"><i>'Set time &amp; date to 23:59:55, Day 2, Date:Month:Year 27:08:2009
    </i></font><b>I2CWRITE </b>SDA,SCL,$D0,$00,[$55,$59,$23,$02,$27,$08,$29,$90] <font color="#000080"><i>' Write to DS1307
    
    </i></font><b>RETURN                  </b><font color="#000080"><i>' Sec Min Hr  Day D   M   Y   Control
    
    </i></font><b>END
    </b></code></pre><!--EndFragment--></body>
    </html>
    Roger

  2. #2
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Many output a square wave from (1Hz to 32kHz for the M41T81). You can monitor it. At 1Hz, a rising edge comes once per second.

Similar Threads

  1. Camera with PIC chip
    By The Master in forum Off Topic
    Replies: 5
    Last Post: - 1st July 2008, 15:28
  2. PIC chip resetting. Very weird
    By The Master in forum Off Topic
    Replies: 0
    Last Post: - 28th October 2007, 18:07
  3. Help on coding/ selecting PIC chip for project
    By lovemeok in forum General
    Replies: 0
    Last Post: - 27th July 2006, 20:21
  4. Best PIC chip..?..
    By Delusional in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th February 2006, 04:17
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th March 2005, 00:14

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