Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    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

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


    Did you find this post helpful? Yes | No

    Default

    Use OPTION_REG = %11010111

    And load the timer on every interrupt.
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Thanks,

    See told you it would be something really simple I missed..

    Code:
    doBAM:
       toggle rs_led
       TMR0 =  158     ' reload the pre-load
       @ INT_RETURN
    (Hey Darrel - how do you get your code blocks so colourful and properly indented ?)

    bill.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by bcd View Post
    (Hey Darrel - how do you get your code blocks so colourful and properly indented ?)
    bill.
    http://www.picbasic.co.uk/forum/showthread.php?t=6221

    The page may take awhile to load.....

  5. #5
    Join Date
    Mar 2006
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Turn Interrupt on/off

    Hello;
    I'm Ryan form the Philippines I must admit DTS-14 ints rules!!! i'd like to know how can i turn the interrupt on and off for USART continues recepton I'm using PIC16f877a toggling register PIE.5 doesn't seem to work

    Thanks

    PS.

    Part of my project i'm paying my tuition continue college again OSY for sometime now hehe (",)

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


    Did you find this post helpful? Yes | No

    Default

    Check out this post, esp. post 5, http://www.picbasic.co.uk/forum/showthread.php?t=3251
    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.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    you can use
    @ INT_ENABLE RX_INT

    and

    @ INT_DISABLE RX_INT
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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 : 8

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