Serin2 and Timer1


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Serin2 and Timer1

    You could just do it by trial and error, let it run for a while and see if and how much it drifts. Otherwise you need to dig into the generated .lst file and count the actual instructions. I'm guessing somewhere around 16 cycles.

    Or, why not use a second timer (TMR0 etc) to actually time it. Stop TMR1, start TMR0, do the reload, stop TMR0, start TMR1. TMR0 will now give you your answer.

    If you tick the timer with the main oscillator it matter if you run at 8kHz or 8MHz, a cycle is a cycle.

    /Henrik.

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Serin2 and Timer1

    I'm confused now by the relationship between the crystal/int osc at 8mhz and the various clocks :?

    So at 8mhz with Fosc/4 & 1/8 prescaler timer1 is ticking at 250,000hz? OK I get that.

    But the sytem instruction clock is operating at? 8mhz instruction cycles a second or Fosc/4 = 2mhz? or something else?

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Serin2 and Timer1

    The asm listing shows these instructions.

    Code:
        MOVE?CT    000h, _T1CON??0
        MOVE?BB    TMR1H, _TMR1RunOn??HIGHBYTE
        MOVE?BB    TMR1L, _TMR1RunOn??LOWBYTE
        ADD?WWW    _PreLoad, _TMR1RunOn, _TMR1RunOn
        MOVE?BB    _TMR1RunOn??HIGHBYTE, TMR1H
        MOVE?BB    _TMR1RunOn??LOWBYTE, TMR1L
        MOVE?CT    000h, _PIR1??0
        MOVE?CT    001h, _T1CON??0
    So how much to add to timer1 reload to compensate I wonder?
    Looking at the data sheet these instructions all seem to need 1 cycle each? So I make that 8 cycles how much is that in TMR1 ticks?

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Serin2 and Timer1

    Hi,
    You are correct, when using any other prescaler than 1:1 one instructioncycle is not equal to one timer tick.

    If you're using 1:8 prescaler then the timer is incremented every 8th instructioncycle but it still doesn't matter if the Fosc is 8kHz or 8Mhz, the relationship between instructioncylce and timertick/count is still the same and that relationship is the prescaler ratio.

    The problem with the ASM-listing that is generated is that it's not "true" ASM, those commands you have in your listing are macros which you then need to "expand" into the "real" ASM instructions. (Did you really find those instruction in the datasheet?) But if it does work out to 8 instructions and your prescaler is 1:8 then it equals exactly 1 timer tick.

    /Henrik.

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