timing equation


Closed Thread
Results 1 to 7 of 7

Thread: timing equation

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Hi,

    INTCON

    bit 2 T0IF: TMR0 Overflow Interrupt Flag bit(2)
    1 = TMR0 register has overflowed (must be cleared in software)
    0 = TMR0 register did not overflow
    Everything works as written ... program loops in interrupt ( I make it short ... lol ) after a first "regular" TMR0 interrupt !!!

    may be should CLEAR the TMR0 Flag ... instead of setting it ... ???

    Just an idea
    Alain
    Last edited by Acetronics2; - 21st November 2008 at 16:23.
    ************************************************** ***********************
    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
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Yep that would help too....;o}
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Untested, but try something like this;
    Code:
    DEFINE OSC 4
    DEFINE OSCCAL_1K 1 ' load factory osccal value
    
    'Register Initializations'
    ANSEL = 0          ' all digital
    CMCON = %00000111  ' set all pins to digital
    TRISIO = %00011111 ' define Inputs and Outputs
    GPIO = %00000000   ' set all pin states to off
    WPU = %00000000    ' shut off weak pull ups
    OPTION_REG = %01010001 ' set the tmr 0 to prescale of 1:4 for 1ms roll over
    INTCON = %10100000 ' ENABLE THE TMR0 INTERRUPTS
    
    'Variables'
    LED VAR GPIO.5
    ROLLOVER_COUNTER VAR WORD
    SECONDS VAR BYTE
    
    LED = 0 ' LED off on boot
    
    ON INTERRUPT GOTO ROLL_OVER
    
    MAIN:
      IF SECONDS = 5 THEN
         ROLLOVER_COUNTER = 0
         SECONDS = 0
         TOGGLE LED
      ENDIF
      GOTO MAIN
    
    DISABLE
    ROLL_OVER:
      ROLLOVER_COUNTER = ROLLOVER_COUNTER + 1 ' INCREMENT ROLL COUNT 1 EVERY 1 ms
      IF ROLLOVER_COUNTER >= 1000 THEN 'created to count seconds instead of ms
         SECONDS = SECONDS + 1
         ROLLOVER_COUNTER = 0
      ENDIF
      INTCON.2 = 0 
      RESUME
      ENABLE 
      
      END
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. 12F683 serout timing
    By Hobie Cat in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 21st December 2009, 16:57
  2. 18F2550 timing
    By sstt1976 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 22nd August 2008, 00:30
  3. Timing inaccuracy - any ideas?
    By Optech in forum General
    Replies: 6
    Last Post: - 7th February 2008, 09:37
  4. Questions on timing
    By malc-c in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2006, 22:38
  5. HSEROUT buffering and timing - 16F88
    By picster in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 5th March 2006, 17:52

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts