Instant Interrupts - Revisited


Results 1 to 40 of 773

Threaded View

  1. #9
    Join Date
    Feb 2003
    Location
    Sydney, Australia
    Posts
    126


    Did you find this post helpful? Yes | No

    Default Issue with Timer0 and setting prescaler

    I have been playing with the code shown below on a 16f737 as I was trying to get different prescaler values into the int routinues. As part of the testing I stripped the code right back to just be a simple interrupt with a value loaded into the pre-load registrer, but I seem to end up with an interrupt time of 204uS. According to the Timer Calc in Mister E's PicMulti Calc I should get an interrupt every 5.019mS. (see attached image for capture of the output waveform - I love my PICkit 2!)

    This code is lifted straight from Darells example with the blinky led (1-2-3 version), and all I have done is add the pre-load. I have also removed the pre-load and still get the same time for the interrupt.

    Code:
    DEFINE OSC 20
    
    rs_led      var portb.7 ' rs232 led
    led         var portc.4 ' was Data_Out line
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
           INT_Handler   TMR0_INT,  _doBAM,   PBP,  yes
         endm
        INT_CREATE     ; Creates the interrupt processor
    ENDASM
    
    OPTION_REG = OPTION_REG & $80 | 1     'Set TMR0 Prescaler to 256, leave RBPU alone
    
    TMR0 =  158 ' preload with 158 to give 21uS interrupts (at 1:1)
    ' this should then give Interrupt every 5.019mS at 1:256
    
    @ INT_ENABLE  TMR0_INT     ; enable Timer 1 interrupts
    '~~~~~~~~~~~~~~~~~~
    
    goto main      ' jump over ISR
    
    '---[TMR0 - interrupt handler]--------------------------------------------------
    doBAM:
    toggle rs_led
    @ INT_RETURN
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~
     high rs_led
    main:
    
    '''''''''''''''''''''''
    ' do some flashing led stuff
    '''''''''''''''''''''''
    high led
    pause 500
    low led
    pause 500
    goto main
    There has got to be something really simple I am missing...
    bill.
    Attached Images Attached Images  
    Last edited by bcd; - 1st May 2008 at 09:19. Reason: Clarification of a few things

Similar Threads

  1. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  2. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 20:02
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  4. Keypad and DT's Instant Interrupts
    By Homerclese in forum General
    Replies: 11
    Last Post: - 27th April 2007, 06:32
  5. Replies: 1
    Last Post: - 1st November 2006, 03:11

Members who have read this thread : 6

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