18F2620 tmr0 and interrupts


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    41

    Default 18F2620 tmr0 and interrupts

    I'm having a bit of trouble converting the EZCLOCK1 code to a 18F2620.

    http://www.picbasic.co.uk/forum/showthread.php?t=2129

    Code:
    OPTION_REG=%00000111   'weak pullups on, TMRO prescale = 256
    INTCON=0               'interrupts off
    Looking at the 18F2620 datasheet that would be changed to T0CON = %11000111 for prescale 256 and 8 bit timer enabled? INTCON=0 should stay the same.

    Code:
    TMR0=0	          'Reset TMRO
    INTCON.2= 0       'Clear TMRO overflow flag
    Now here is what starts to confuse me. I'm not sure about TMR0 and the overflow flag is now called TMR0IF.

    Code:
    Main:
    ClockLoop: IF INTCON.2=0 THEN ClockLoop ' Wait for TMRO overflow
    INTCON.2=0 'Clear TMRO overflow flag
    At this point how is the timer being enabled? The code works fine with a few minor changes on a 16F876A but this my first encounter with the 18F series. Any comments?


    Adam

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by astouffer View Post
    At this point how is the timer being enabled?
    On 16F's, TMR0 doesn't have an ON bit. It's always running.
    On 18F's TMR0ON is T0CON.7, which you indicated as a 1. "T0CON = %11000111"

    When using it as an 8-bit timer, the timers value is in TMR0L. On 16F's it's just TMR0.

    And yeup, T0IF is now TMR0IF. There are also some 16F's that call it TMR0IF so it's always confusing.
    But at least it's still INTCON.2 no matter what you call it.
    <br>
    DT

  3. #3
    Join Date
    Nov 2008
    Posts
    41


    Did you find this post helpful? Yes | No

    Default

    All is working as it should. Many thanks.


    Adam

Similar Threads

  1. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 04:52
  2. 18F2420, instant interrupts, and TMR0
    By dhickman in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th March 2009, 18:33
  3. TMR0 interrupt and HSERIN
    By boban in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd September 2008, 11:48
  4. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 15:10
  5. Strange behaviour from PIC16F877 on TMR0
    By mikebar in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 19th August 2006, 01:31

Members who have read this thread : 1

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