Making a timer, 32.768kHz+555+DT_INT. Good idea?


Closed Thread
Results 1 to 38 of 38

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Are you saying that you have two 32768 crystals?
    The CPU will be running at 8192 hz (FOSC/4).

    You might as well run the timer off the main clock then, (saves the power used by the timer1 oscillator), and gives the same accuracy.
    T1CON = 1
    Reload TMR1H with $11100000, and definitely put it First in the handler.

    And change the LCD timing because PBP still thinks it's running at 4mhz.

    DEFINE LCD_COMMANDUS 17
    DEFINE LCD_DATAUS 1
    With recommended settings above i.e. TMR1H with %11100000 can someone please help me understand how many seconds or minutes the clock will be out after a month or an year because it gives me 1.00069 Hz frequency for Timer1
    ___________________
    WHY things get boring when they work just fine?

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


    Did you find this post helpful? Yes | No

    Default

    That would gain about 2.5 seconds per hour, which is not good.

    Have you set LP oscillator mode in your configs?
    Since it worked for you at 4mhz, it's probably set to XT and over driving the crystal.

    How are you measuring that frequency?
    Is it a high quality frequency counter?
    Accurate measurements of low frequencies can be difficult, with large errors.
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    That would gain about 2.5 seconds per hour, which is not good.

    Have you set LP oscillator mode in your configs?
    Since it worked for you at 4mhz, it's probably set to XT and over driving the crystal.

    How are you measuring that frequency?
    Is it a high quality frequency counter?
    Accurate measurements of low frequencies can be difficult, with large errors.
    Yes, I change it to LP when driving it with 32 kHz and your advised process to run timer 1 from internal clock (loading TMR1H=%11100000) & XT when 4MHz (with 32kHz attached 4 TMR1).

    For frequency, unfortunately I am not equipped with those luxuries, I am just using an Timer Calculator I found in the Forum only. Screenshot attached.
    Attached Images Attached Images  
    ___________________
    WHY things get boring when they work just fine?

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Even with loading 32768 into TMR1, the calculator shows the interrupts 1.00027 Hz.
    This is just to seek clarification, it is unlikely that I will be able to use 4MHz for OSC & 32kHz for TMR1.
    ___________________
    WHY things get boring when they work just fine?

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


    Did you find this post helpful? Yes | No

    Default

    That calculator is wrong.

    Here's the way it works ...
    The main OSC is running at 32768 hz.
    The CPU is running a 8192 hz (32768 / 4).

    Timer1 is loaded with the highbyte of 57344 and will overflow at 65536.
    65536 - 57344 = 8192

    So the timer overflows exactly 1.0000 seconds every time (depending on the crystal tolerance).
    DT

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    That calculator is wrong.

    Here's the way it works ...
    The main OSC is running at 32768 hz.
    The CPU is running a 8192 hz (32768 / 4).

    Timer1 is loaded with the highbyte of 57344 and will overflow at 65536.
    65536 - 57344 = 8192

    So the timer overflows exactly 1.0000 seconds every time (depending on the crystal tolerance).
    OK, I am now running everything as advised. I synchronised the time with my phone last night. Today appx after 12 Hrs, the phone is appx 6 seconds ahead than the clock. What could be the possible problem?
    ___________________
    WHY things get boring when they work just fine?

  7. #7
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Financecatalyst, I would first check that the crystal is indeed operating at the proper frequency... (Frequency counter)

    Dave Purola,
    N8NTA

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