tmr2 interrupt problem


Closed Thread
Results 1 to 28 of 28

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    EDIT2: Thought i saw that before...

    One thing i discover in your code...
    Code:
    LOOP:
            I2CRead DS_SDA,DS_SCL,$D0,$00, [sec,MINs,hr,day,date,mon,yr] ' Read Ds1307 
            	If sec.7=1 then goto coldstart	
                If setbutton = 0 then       'if setbutton is pressed
                    _hr=hr
                    _min=MINs
                    _sec=sec
                 gosub SetButtonRelease    
                 Gosub SetTimeAndDate 'after release    
               endif
            counter3=0
            repeat     'show the segments for 5 times.
                pauseus 10    
                until counter3 > 5
            GoTo Loop
    You don't increment Counter3 variable.. so it will never jump to Loop... hence maybe why it works when you're using RESUME LOOP...

    Same thing in PauseLoop
    Code:
    Pauseloop: 'some timedelay
            counter3=0
            repeat
                pauseus 10
            until counter3 > 50
            return
    and
    Code:
    '------------------------------------
    SetButtonRelease: 'delay for button
    	counter3=0
        while setbutton=0
            pauseus 10
        Wend
    	if counter3=>29 then
            repeat
                pauseus 10
            until counter3 > 70
        else 
            goto loop    
        endif
        Return
    I'll wait before building it
    Steve

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

  2. #2
    Join Date
    Dec 2007
    Location
    The Netherlands, Groningen
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    hi, the counter3 has not to be the problem. It is incremended everytime it go's to the ISR. If you look at the top of the ISR you see:
    Code:
    if counter3=>200 then 'number of shiftouts
    counter3=0
    else 
    counter3=counter3+1
    endif
    So it stays in stat loop until the ISR is called for 'counter3' time's.
    So it's a kind of delayloop.

    Is there an other wat to go to the ISR at the timerinterrupt then ON INTERRUPT?

    I go to try comment the code to a minimize is left and use 'return' at th end of the ISR.

    To make clear that there are no mistakes: I tried to make the program work in loops and every time the timerinterrupt sets it's flag jumps it to the ISR to shiftout the displayvalues, afther that it go's back to twere it was en finish the loop so it can start again waiting for a buttonpress.

    I'm sorry, I thing it will be tomorrow that this is finished. It's buzy over here...
    Last edited by ADCON; - 31st December 2007 at 16:18.

  3. #3
    Join Date
    Dec 2007
    Location
    The Netherlands, Groningen
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    i changed my code now.
    the var counter works fine.

    Code:
    LOOP:
    
    
    Sec=12
    Mins=34
    hr=56
    
    if counter3=>100 then
    blink=1
    else 
    blink=0
    endif
    goto loop
    end
    This is with only the return-command.

    I'm going to change the loop now. I try to set more gosubs in it, maby it works..

    [s]It looks like there is a problem between the I2C and interrupt. Do's I2C also use timer2 for it's clocksignal or something?[/s]
    edit:
    I found a mistake:
    @ loop:
    goto coldstart

    @ coldstart
    return



    not all the problems are solved now, but at least return at the end of the ISR dos have any effect!

    edit2:
    after changing the tris settings to
    TRISA=%11111111
    TRISB=%11111111
    I can make some input with the buttons. The problem now is that it's menu is not working right.
    It looks like it just runs the routine for once and not wait for any other input.(possible a mistake when I did change it from only loops to interrrupt I might have did something wrong..). I have to look at that for now..
    Last edited by ADCON; - 1st January 2008 at 15:51.

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


    Did you find this post helpful? Yes | No

    Default

    None of I2C function use the internal timer, but they need time to execute. I should be able to build the board today.

    Out of curiosity... did you also tried to test it with ISIS?
    Steve

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

  5. #5
    Join Date
    Dec 2007
    Location
    The Netherlands, Groningen
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    I have no licence of ISIS. If I had I would be happy
    Well, I have now the clock working(it means running the way it has to do) and it looks like the settings of the menu is now a software-thing what I have to debug and modificate. My old version did work but to make it timerinterrupt I had to change the code. So, I think I have make some mistakes at that part of the job. It looks like it runs the menu for one time and don't wait for inputs.
    For this part thanks for all your help!

    It is a option to use also a interrupt for the inputbuttons...

  6. #6
    Join Date
    Dec 2007
    Location
    The Netherlands, Groningen
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    Well, its working finally!

    The only thing is that the display dos not change when a button is pushed-in. so, when you hold your hand on a button so it will count crom 1,2,3,4 and release it by five, you see the 1 untill you release the button.
    I have to finish that part..

Similar Threads

  1. Problem with Interrupt on PIC18F4620 PORTB
    By rookie in forum Off Topic
    Replies: 1
    Last Post: - 22nd March 2007, 01:34
  2. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02
  3. Interrupt Problem
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th November 2005, 20:58
  4. Interrupt stack overflow problem with Resume {label}
    By Yuantu Huang in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 3rd May 2005, 01:17
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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