Accurate clock using 12C508


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Posts
    24

    Default Accurate clock using 12C508

    I need to build a circuit that accurately toggles two outputs (1 high, 1 low) every minute. My initial idea was to use the 1Hz output from a DS1307 RTC, and counting to 60.

    However, I thought a neater idea was to run the 12C508 from either a 32.768KHz or 4.9152MHz Crystal, and use the program counter to determine the timing.

    Is this feasable, and if so can I do it in PBP, or how do I do it in assembly?

  2. #2
    Join Date
    Oct 2005
    Location
    Loveland CO USA
    Posts
    83


    Did you find this post helpful? Yes | No

    Default

    There are hounds of ways to build this.
    Use 12F510 or any of the little 10Fxxx parts.
    Use the 32768 watch crystal.
    In assembly, build the code to toggle the a out put pin. (10 instructions or less) Then build a kill time loop that takes (32768 * 60 – 10) instructions.
    OR
    In PBP use the pause instruction.
    OR
    Set up timer0 and prescaller to role over every 4 seconds. (Fosc/4)/128/256) Every 15 of those toggle the output. You software is looking for timer role over and counts to 15.
    OR
    ?

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    There are hounds of ways to build this.
    Use 12F510 or any of the little 10Fxxx parts.
    Use the 32768 watch crystal.
    In assembly, build the code to toggle the a out put pin. (10 instructions or less) Then build a kill time loop that takes (32768 * 60 – 10) instructions.
    OR
    In PBP use the pause instruction.
    OR
    Set up timer0 and prescaller to role over every 4 seconds. (Fosc/4)/128/256) Every 15 of those toggle the output. You software is looking for timer role over and counts to 15.
    OR
    ?
    search the www for ideas from Roman Black
    http://www.romanblack.com/one_sec.htm

  4. #4
    Join Date
    Jun 2004
    Posts
    24


    Did you find this post helpful? Yes | No

    Smile Thanks for help

    In the end I used the TMR0 timer and wrote the program in assembly (my first attempt at assembly on a PIC!). Using a 32K768Hz crystal, I set the prescalers to 1/256 to give 32Hz, and then counted to 1 second sixty times!

    OPTION_REG=%00000111

    TRISIO=0

    cnt var byte $0F system

    ASM

    CLRF GPIO
    CLRF STATUS
    CLRF cnt ;clear registers
    CLRF TMR0
    LOOP BTFSS TMR0,5 ;count to 1 second
    GOTO LOOP
    CLRF TMR0
    INCF cnt,W
    MOVWF cnt
    CLRF GPIO ;switch off coil
    XORLW 60 ;count to 1 minute
    BTFSS STATUS,Z
    GOTO LOOP
    CLRF cnt ;clear counter
    CLRF STATUS
    BSF GPIO,0 ;turn on coil+
    LOOP1 BTFSS TMR0,5 ;count to 1 second
    GOTO LOOP1
    CLRF TMR0
    INCF cnt,W
    MOVWF cnt
    CLRF GPIO ;switch off coil
    XORLW 60 ;count to 1 minute
    BTFSS STATUS,Z
    GOTO LOOP1
    CLRF cnt ;clear counter
    CLRF STATUS
    BSF GPIO,1 ;turn on coil-
    GOTO LOOP

    ENDASM

Similar Threads

  1. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  2. EM4095 Chip, get Clock and Data signals?
    By mindthomas in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 19th August 2008, 06:27
  3. Shiftout/in
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd August 2007, 11:48
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. Accurate 32.768 k clock
    By peterk in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th July 2004, 23:04

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