DT-ints-18, How to ...


Closed Thread
Results 1 to 19 of 19

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: DT-ints-18, How to ...

    Hi,
    It's easy but I'm afraid it's not THAT easy - there is no TMR1 register (hence the error). Instead TMR1 consists of TWO 8bit regsiters, TMR1L and TMR1H.

    The straight forward way to write it is to do
    Code:
    TMR1L = 0
    TMR1H = 0
    And the straight forward way to read it is
    Code:
    myVar VAR WORD
    myVAR.HighByte = TMR1H
    myVAR.LowByte = TMR1L
    When reading TMR1 this way there's a slight posibillity that TMR1L overflows right in between reading TMR1H and TMR1L giving you a wrong result. To prevent that the easiest way is to simply STOP the timer before reading it. If that's not possible there are other ways to cater for that - and there are tricks that allows you to read it in one go if needed but lets keep it as simple as possible for now.

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default Re: DT-ints-18, How to ...

    If you are using the Timer Template, then there's no reason to read or write to the Timer directly. It is handled for you by the template.

    If you are not using the template, you should at least use the Timer Reload routine from the template.
    To maintain a constant frequency that also accounts for interrupt latency, the reload value must be ADDED to the current value in the Timer.

    Just reloading a value into the Timer will give a frequency output, but accuracy and consistency will suffer.

    There are other ways to ADD the reload value to the Timer, but you must know exactly how many instructions it takes to do the addition.
    The routine in the template is already known to take 8 instruction cycles.
    The template automatically adjusts for that amount of time.

    With the template, if you tell it you want 100hz ... you get 100.0 Hz.

    With all of that said ... you still haven't revealed whether you want a Fixed frequency or Variable frequencies?
    It makes a huge difference.
    DT

  3. #3
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: DT-ints-18, How to ...

    Thanks to everybody for the assistance.
    yes, I need a fixed frequency so I can use the timer tamplate. >> Is this table applicable to pic18f4523 ?
    Additional question:
    >> what is the purpose of bit_7 ( rd16 ) in the t1con register? How to use it ?
    >> what is the purpose odf the RESETFLAG? yes/no in the DT _int ?
    Regards,
    Ambrogio

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


    Did you find this post helpful? Yes | No

    Default Re: DT-ints-18, How to ...

    The table is applicable to all PIC's, but it doesn't include the higher OSC frequencies of the 18F's.

    If your interrupt frequency is greater than 160 Hz (80 Hz Full Cycle), you don't need to worry about the table.
    Just set Prescaler to 1 and Freq to your frequency.

    The RD16 bit buffers the highbyte of the Timer so that both bytes can be read or written without stopping the Timer.
    The Timer Template will not work with RD16 set.

    With interrupts that require you to manually clear the interrupt flag, setting RESETFLAG to YES will allow DT_INTS to clear it for you.
    DT

  5. #5
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: DT-ints-18, How to ...

    Thanks again Darrel for the great assistance.
    regards,
    Ambrogio
    IW2FVO
    North Italy

Similar Threads

  1. DT INTs which int to use??
    By Heckler in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 13th March 2012, 00:23
  2. out of memory using DT-ints-14 and 16F610
    By comwarrior in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th January 2011, 03:30
  3. DT-INTs Blinky Light question
    By circuitpro in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 5th February 2010, 03:29
  4. Problem with Dt Ints Interrupts
    By Quin in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th July 2008, 19:21
  5. DT-ints-18 - new version
    By dip1 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 10th October 2007, 20:09

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