Working clock example using 32K watch crystal


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    ' Description : PicBasic Pro program using external 32K watch xtal and Timer1
    But 50% of the program is in assembler

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    But 50% of the program is in assembler
    Then show him how it's done. (in straight PBP)
    This task is worth 2 free 4x20 Parallel LCD's ... shipping outide of US/Canada extra.

    In case of multiple responses ... style will prevail.
    As judged by Darrel Taylor
    Ends 11/10/2010 Midnight Mountain Time
    DT

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Talking Naw only just point the way

    INCLUDE "DT_INTS-18.pbp" ; Base Interrupt System
    INCLUDE "ReEnterPBP-18.pbp" ; Include if using PBP interrupts"
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Jan 2005
    Location
    Boston MA
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    The earlier versions I wrote had NO asm but lost almost a minute an hour. To make up for that one could re-tune using TMR1H and TMR1L with a larger value. Problem is every change made to the program would mean spending a few days retuning and it would never be as precise.

    So yea I would love to be able to do this without asm in PBP AND be as accurate!

    Down the road I intend to join this interrupt sample with a SNTP internet program so I can have a near perfect millisecond low power $60 clock.

    Regards
    Tim C

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Code:
       ' Int handler doesn't mess with any PBP system variables - or lower 15-bits
       ' of TMR1 accumulated time. Uses only 4 instructions to set TMR1H high bit,
       ' increment seconds, clear the interrupt flag bit, save & restore WREG, STATUS,
       ' BSR and return from int handler.
     
    @myint                  ; create myint label
       TMR1H.7=1            ' Set TMR1 high bit for 1 second overflows
       seconds = seconds+1  ' Increment seconds
       PIR1.0=0             ' Clear TMR1 int flag
       @ retfie  FAST       ; Return with 'auto restore' of WREG, STATUS and BSR
    Should do it.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Then show him how it's done. (in straight PBP)
    I wish --- (I'll remove my tongue from in my cheek now )

  7. #7
    Join Date
    Jan 2005
    Location
    Boston MA
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Thank you Bruce
    Smaller, tighter, yet perfect speed. Started the clock last night with your change and so far the PIC18F452 has not gained or lost one second.
    Tim C

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi,

    I didn't see that one :
    http://www.pbpgroup.com/modules/wfse...hp?articleid=8

    did I miss something ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  9. #9
    Join Date
    Jan 2005
    Location
    Boston MA
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Alain,
    Darrel's great example uses one crystal mine uses 2. And oh if something is sitting there soldered to the dev board and you don't have code to see if it works!!

  10. #10
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by timc View Post
    Alain,
    Darrel's great example uses one crystal mine uses 2. And oh if something is sitting there soldered to the dev board and you don't have code to see if it works!!
    Hi, Timc

    Lol ... I didn't remember I had modified Darrel's code to use a 32 Khz Xtal ...

    and thought it was already done in the original release ...

    Here it is.

    Alain
    Attached Files Attached Files
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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