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


Closed Thread
Results 1 to 38 of 38

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    There's the problem ...
    Code:
    TMR1L=0
    TMR1H=128
    @ INT_RETURN
    By the time it gets all the way through the interrupt handler, another tick or two may have been counted by Timer1.
    That gets lost when you reload both bytes of the Timer.

    For 32768 crystals, the reload is really simple ...
    Code:
    TMR1H.7 = 1
    And it's best to put it at the beginning of the handler.
    Although in your case, the handler is fast enough it won't matter were it is.
    DT

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    There's the problem ...
    Code:
    TMR1L=0
    TMR1H=128
    @ INT_RETURN
    By the time it gets all the way through the interrupt handler, another tick or two may have been counted by Timer1.
    That gets lost when you reload both bytes of the Timer.

    For 32768 crystals, the reload is really simple ...
    Code:
    TMR1H.7 = 1
    And it's best to put it at the beginning of the handler.
    Although in your case, the handler is fast enough it won't matter were it is.
    I did TMR1H.7=1, but the code is not entering the interrupt. I checked it with changing it to TMR0, it works. Am I making a mistake in setting up timer1?
    ___________________
    WHY things get boring when they work just fine?

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by financecatalyst View Post
    I did TMR1H.7=1, but the code is not entering the interrupt. I checked it with changing it to TMR0, it works. Am I making a mistake in setting up timer1?
    T1CON=%00001010 ; Timer 1 settings towards the beginning of the code

    You might want to turn the Timer ON.
    DT

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Sorry Darrel, I put Timer1 On now, but the problem is still there.

    T1CON=%00001011
    Further investigation revealed that this bit is the problem. Looks like in the simulation software I need to look into crystal setup again. I tried with this bit cleared and it worked fine.
    Last edited by financecatalyst; - 19th December 2010 at 02:03. Reason: Updated info
    ___________________
    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

    With that bit cleared, Timer1 is clocked from FOSC/4 instead of the Timer1 oscillator.

    What simulator are you using?
    DT

  6. #6


    Did you find this post helpful? Yes | No

    Default

    I am using Proteus 6.9 (which I am also new to).
    Screenshot of the setup is attached.
    It is not working with external clock settings on timer 1
    I tried changing capacitor values, crystal values but no response.
    Attached Images Attached Images  
    ___________________
    WHY things get boring when they work just fine?

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


    Did you find this post helpful? Yes | No

    Default

    Hmmm, apparently the Timer1 oscillator doesn't work.

    Instead ... exclude the crystal and caps from the simulation, and add a clock generator on the T1OSI input.



    Set it up like this.

    DT

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