Darrel Taylor Elapsed Timer


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    I'll double check that, but if that were the case, wouldn't my baud rates and stuff be off as well on my serial port stuff?

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


    Did you find this post helpful? Yes | No

    Default

    Yes it would.
    Didn't realize you had serial working along with the problem.
    Thought maybe it was just an LCD, which wouldn't be affected.

    Do you have other interrupts in the program too?
    Something that might be keeping the interrupts locked up for too long?
    <br>
    DT

  3. #3
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    Yes, I have one other that's for Rx but it grabs a short 8 byte serial string once every 2 seconds.

    INCLUDE "DT_INTS-18.bas" ; Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas" ; Include if using PBP interrupts
    INCLUDE "Elapsed_INT-18.bas" ; Elapsed Timer Routines

    ASM
    INT_LIST macro ; IntSource, Label, Type, ResetFlag?
    INT_Handler RX_INT, _Receive, PBP, yes
    INT_Handler TMR1_INT, _ClockCount, PBP, yes
    endm
    INT_CREATE ; Creates the interrupt processor
    ENDASM

    @ INT_ENABLE RX_INT ; enable external (INT) interrupts
    @ INT_ENABLE TMR1_INT ; enable external (INT) interrupts


    15 seconds is a long time and is pretty consistient.

  4. #4
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    I did check, and I do have the following fuses set in my programmer.

    Osc = HS, FSCM = on, Brown Out = Enabled,
    Low Power Timer1 Osc = Low Power ??? Was default

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


    Did you find this post helpful? Yes | No

    Default

    Try it like this, and see if the Low Priority RX_INT helps.
    Code:
    DEFINE  USE_LOWPRIORITY  1
    INCLUDE "DT_INTS-18.bas"       ; Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"    ; Include if using PBP interrupts
    INCLUDE "ReEnterPBP-18LP.bas"  ; Include if using Low Pr. PBP INTS
    INCLUDE "Elapsed_INT-18.bas"   ; Elapsed Timer Routines
    
    ;----[High Priority Interrupts]-----------------------------------------------
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ClockCount,   PBP,  yes
        endm
        INT_CREATE               ; Creates the High Priority interrupt processor
    
    ;----[Low Priority Interrupts]------------------------------------------------
    INT_LIST_L  macro  ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler     RX_INT,     _Receive,   PBP,  no
        endm
        INT_CREATE_L             ; Creates the Low Priority interrupt processor
    ENDASM
    
    @    INT_ENABLE  TMR1_INT     ; Enable Timer 1 Interrupts  
    @    INT_ENABLE  RX_INT       ; Enable USART Receive interrupts
    DT

  6. #6
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    That works better.


    Is this causing my problem since they are PBP Interrupts, it's not exiting like it should...

    AdcMaxReads is at 64, Each time I loop I increment the channel, that way I only do 64 reads per loop.


    GetADC:
    ADCVAL = 0
    ADCAVG = 0

    For AdcCnt = 1 to AdcMaxReads
    ADCIN NextChan,ADCVAL
    ADCAVG = ADCAVG + ADCVal
    Next AdcCnt
    Reg[NextChan] = ADCAVG / AdcMaxReads

    NextChan = NextChan + 1
    If NextChan = 10 then 'Cycled thru all 9 analogs
    If (LowBatSP > 0) Then
    BatVolts = Reg[8]
    GoSub CheckBat
    EndIf
    NextChan = 0
    EndIf
    Return





    Main:
    Gosub GetADC
    Goto Main

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


    Did you find this post helpful? Yes | No

    Default

    Those A/D statements are in the Main Loop, they will not have any affect on the interrupts.
    However, you haven't initialized the NextChan variable before starting. It may take several thousand readings from invalid channels before falling back into line when it rolls over.
    But much like the RX handler, you may not have included that part of the program.

    That works better.
    Does that mean it's counting at 1 second intervals now?

    If so, then the problem is in your RX handler. If you have a Timeout value in the HSERIN statement, it sits in the interrupt until it either receives ALL the data, or it times out. Or if there's no timeout, it simply waits until it's received enough data before returning.

    If that handler is a High Priority interrupt, then no other interrupts can occur until it's returned from that handler. Timer1 would then probably miss many interrupts.

    By making the RX handler a Low Priority interrupt, it allows the (high priority) TMR1_INT to continue on without conflict.
    <br>
    DT

Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 17:39
  2. High Resolution Timer & Speed Calculator
    By WOZZY-2010 in forum Code Examples
    Replies: 4
    Last Post: - 7th February 2010, 16:45
  3. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th January 2009, 23:49
  4. using darrel taylor's instant interrupts
    By Michael Wakileh in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 31st July 2007, 04:07
  5. timer interupt help 16f73
    By EDWARD in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd July 2005, 08:41

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