Another interrupt question


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107

    Default Another interrupt question

    I'm trying to get a timer interrupt to work, but the code below just doesn't run.
    Can someone please tell me what I'm doing wrong? It seems like the ISR isn't getting called.
    __________________________________________________ ____________

    DEFINE OSC 4

    DEFINE INTHAND TMRint


    ADCON1 = 7
    RCSTA = $90
    TXSTA = $24
    SPBRG = 25


    wsave VAR BYTE bankA system
    ssave VAR BYTE bankA system
    fsave VAR WORD bankA system '

    ASM_Seconds VAR BYTE bankA

    T0CON = %10000101

    Seconds VAR BYTE
    OldSeconds VAR BYTE

    OldSeconds = 0
    ASM_Seconds = 0

    GoTo START


    Asm
    TMRint
    movwf wsave
    swapf STATUS, W
    clrf STATUS
    movwf ssave

    movf Low FSR0, W
    movwf fsave
    movf High FSR0, W
    movwf fsave+1

    ; Do the real work here
    ;------------------------------------------------------------------------------

    incf _ASM_Seconds,1
    clrf TMR0IF
    ;----------------------------------------------------------------------------

    movf fsave, W
    movwf Low FSR0
    movf fsave+1, W
    movwf High FSR0
    swapf ssave, W
    movwf STATUS
    swapf wsave, F
    swapf wsave, W
    retfie
    EndAsm


    START:
    INTCON = %11100000 ' Enable TIMR0 interrupts

    MAINLOOP:

    GoSub GetSecs

    IF Seconds <> OldSeconds THEN
    OldSeconds = Seconds
    HSEROUT [#Seconds," "]
    EnDIF
    GoTo MAINLOOP

    GetSecs:
    INTCON.7 = 0 ' Shut off interrupts when reading register
    Seconds = ASM_Seconds
    INTCON.7 = 1
    Return

    End
    Charles Linquist

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Charles Linquis,I never see you setting the TMR0 value which means you are allowing it to overflow every 4.194 seconds. (1/4000000)x4x64x65536). This is assuming your TMR0 is a 16 bit timer.

    Dave Purola,
    N8NTA

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I realize that I have to jam the timer with a value, I'll calculate that value when I get things running. The problem is - the ISR NEVER seems to get called.
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default

    Hi Charles,

    Change clrf TMR0IF to bcf INTCON,TMR0IF. Everything else looks OK.
    Regards,

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

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    That was it!

    Thanks, Bruce.
    Charles Linquist

Similar Threads

  1. Interrupt question
    By ultiblade in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 26th November 2009, 20:12
  2. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  3. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  4. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07
  5. Interrupt question
    By stone in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 25th January 2005, 23:11

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