TMR0 as counter


Closed Thread
Results 1 to 24 of 24

Thread: TMR0 as counter

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Or you could just count the Overflows from timer0 and make it a 16-bit or larger counter.

    DT

  2. #2
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Or you could just count the Overflows from timer0 and make it a 16-bit or larger counter.

    DT
    Now count the TMR0 and also count the prescaler (256)

    result var word ' 16 bit result of count, high from tmr0 low from prescaler
    TMR0 = result.Byte1
    prescaler = result.Byte0

    But i cann't take the decimal numbers , only the integer
    Last edited by savnik; - 21st June 2008 at 12:10.

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Savnik,

    I understood that you already have a PCB and can not change it.

    Then, if you are not using RB6, then just short it to RA4 manually with a tiny cable and use Timer1.

    -----------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  4. #4
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    Then, if you are not using RB6, then just short it to RA4 manually with a tiny cable and use Timer1.-----------------
    unfortunately i use RB4-RB7 for LCD

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Post

    Quote Originally Posted by savnik View Post
    Now count the TMR0 and also count the prescaler (256)

    result var word ' 16 bit result of count, high from tmr0 low from prescaler
    TMR0 = result.Byte1
    prescaler = result.Byte0

    But i cann't take the decimal numbers , only the integer


    Hi, Savnik,

    so, you want to use a ... 24 bits counter !!!

    One more good reason to turn to 18F1320 AND use PBPL ... instead of PBPW !

    But, once more ... will you tell us the PIC Osc frequency and the frequency range you intend to measure at PORTA.4

    ... as I smell something really interesting ...

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

  6. #6
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Savnik,

    so, you want to use a ... 24 bits counter !!!

    One more good reason to turn to 18F1320 AND use PBPL ... instead of PBPW !

    But, once more ... will you tell us the PIC Osc frequency and the frequency range you intend to measure at PORTA.4

    ... as I smell something really interesting ...

    Alain
    Now i use xtal 4mhz and the frequency range is from 300khz to 6mhz

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    But i cann't take the decimal numbers , only the integer
    And yet AGAIN!!!
    PBP doesn't do fractional numbers by default!!!!! NEVER has, NEVER will!!!
    You have to create your own method to extract any fractions you need.
    Multiply the number your dealing with by 100, the 2 rightmost digits are your fraction....simple as that!
    Or maybe not...
    Last edited by skimask; - 21st June 2008 at 21:23.

  8. #8
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default TMR0 overflow

    Another question.

    I use TMR0 as counter to measure the frequency at RA4
    How i know, how many times the TMR0 overflow.
    The maximum times is 3

    For first overflow INTCON.2 = 1 , After;

    pic16f88
    xtal =4mhz
    option_reg = %10110111
    Last edited by savnik; - 23rd June 2008 at 12:59.

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    For first overflow INTCON.2 = 1 , After;
    So clear it and at the same time, increment an 'overflow counter'.

  10. #10
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    So clear it and at the same time, increment an 'overflow counter'.
    I have make this but increment only for 1


    Code:
            overflow = 0
    main:       
            TMR0 = 0
    
            'start count                      
            pauseUS 1000                          
            'stop count
    
            if INTCON.2 = 1 then overflow = overflow + 1           
            INTCON.2 = 0 
            Temp = TMR0
            gosub LCD
            goto main
    Last edited by savnik; - 23rd June 2008 at 16:07.

  11. #11
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    Another question.

    I use TMR0 as counter to measure the frequency at RA4
    How i know, how many times the TMR0 overflow.
    The maximum times is 3

    For first overflow INTCON.2 = 1 , After;

    pic16f88
    xtal =4mhz
    option_reg = %10110111
    Until today i don't solve this problem.
    To know how many times TMR0 has overflow;

  12. #12
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    Until today i don't solve this problem.
    To know how many times TMR0 has overflow;
    So did you solve the problem, or not solve the problem?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  13. #13
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default No

    Quote Originally Posted by Joe S. View Post
    So did you solve the problem, or not solve the problem?
    No.
    I use TMR0 as counter to measure the input frequency at RA4 for 256ms.
    The frequency is between 0.3mhz and 8mhz.
    My problem is how many times the TMR0 overflow.
    I use pic16f88 and 4 mhz xtal. (I don't to change these)

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 15:10
  3. 20 Digit Virtual LED Counter
    By T.Jackson in forum Code Examples
    Replies: 9
    Last Post: - 19th November 2007, 05:02
  4. using TMR0 as a counter..
    By sirvo in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th July 2007, 02:56
  5. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27

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