Synchronising Timer0 and Timer1


Closed Thread
Results 1 to 9 of 9

Hybrid View

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


    Did you find this post helpful? Yes | No

    Wink

    Hi, Duncan

    This is the same question as " I want to measure the 100th of degree with a LM35 and VDD ref " ...

    99 times upon 100 ... no real need ... exept "for the show" ... but 1% remain useful ...

    but, good exercise to have a reflexion about what offers the chip as features ...

    Alain
    Last edited by Acetronics2; - 9th April 2008 at 12:31.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  2. #2
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146


    Did you find this post helpful? Yes | No

    Default

    but, good exercise to have a reflexion about what offers the chip as features ...
    your are quite right Alain.

    I have taken a very big step away from the bench for a while now, (just can’t seem to get the level of concentration back).

    There are so many ways of achieving a result that sometimes I have had difficulty seeing through the “liminal”. And by that I mean the mental area where I can unnecessarily execute a task in PBP that can be completed very simply using the inbuilt features of a PIC, and Visa-versa
    Approaching a problem from a PIC perspective or PBP Perspective. And I haven’t started on peripheral components.

    So it is really valuable to have a reflection

    I am in a mental state where I am looking at code and circuits and simply cannot believe they are mine, what they are for and why I build them in the first place. I am finding it quite depressing.

    Anyway, I am hijacking a thread again, so back to it,

    On a 252 I might set an interrupt on the two comparators (single interrupt only inbuilt I think) for each channel that I wish to monitor and use that interrupt event to start one timer with a preload and interrupt on overflow…..Whilst……. using the other two CCP and associated timers to capture all the events on the two channels.

    So I might have THREE consecutive lines starting each of the three timers, just as Alain suggested

    If the events on the two CCP channels are very close together and are triggered before the reset/write is completed then consider a PIC with more Timers that can be associated with the CCP’s so that each subsequent trigger on a particular channel uses a different timer.

    Is every edge being triggered (random pulses) or is it looking at a frequency. So much of this is application specific.

    Duncan

  3. #3
    Join Date
    Feb 2006
    Location
    Isle of Man
    Posts
    32


    Did you find this post helpful? Yes | No

    Cool Synchronising Timer0 and Timer1

    Thanks for the response folks! I need to determine the EXACT frequency difference between the 2 channels, with frequencies in the 2MHz range. Both frequencies are changing continuously and are close (or equal) all the time. The PIC clock is 20MHz. In my application a single count difference between channels is significant, so the lag caused by coding the Start/Stop on successive program lines will give rise to an error.

    From reviewing your replies, it seems to me that the only totally satisfactory solution is to:

    1 Gate both channels externally using a pair of AND or NAND gates, enabling these via a spare PIC pin
    2 Start both timers in the program
    3 Then feed both timers by enabling the gates
    4 Disable the gates to stop the feed
    5 Then read Timer0 and Timer1.

    It's just a shame that we need to add a clunky 14 pin IC to do this trivial job!

Similar Threads

  1. ASM code
    By Bill Legge in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 1st March 2010, 23:55
  2. Need help with INTerrupts
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd August 2007, 00:53
  3. 16F690 TIMER0 and TIMER1
    By nickdaprick in forum mel PIC BASIC
    Replies: 2
    Last Post: - 18th April 2007, 14:49
  4. Low-Frequency Counter
    By Zeke in forum General
    Replies: 7
    Last Post: - 19th January 2006, 18:06

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