tmr2 interrupt problem


Closed Thread
Results 1 to 28 of 28

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Yes, sim programs are expensive. I had a free beta-testversion once, it had still to much bugs to work with, after that came the pay-version.. I also like to life-test also my bankaccount.. it only takes sometimes some more time. But the good side is that when it workt it really works and with sim-programs is that always a question..

    Well, Possibli can you tell me the length of a I2Cread/write procedure because I think that it is also to long. When I start the timer after the ISR it will only read the RTC, it never finishes the coldstart.

    I did try to set the prescale to 1:16 but it hadn't any good progress. How do I become a timerinterrupt every 8mSec? of 16msec? Maby I can thy that so it works..

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


    Did you find this post helpful? Yes | No

    Default

    Well the prescaler was already 1:16 at the first post.. hence why you didn't had any better results
    Now what you need to do is to use the POSTscaller. if you set the postscaller to 1:2 you'll have a 2mSec*Prescaller int. 8mSec, postscaller 1:4 and so on
    Code:
            T2CON = %00011010
                    'X------- Unimplemented
                    '-0011--- postscale 1:4
                    '-----0-- Timer2 off
                    '------10 prescaler 1:16
    seems to work with the second suggestion
    Code:
    // Snip
            ON INTERRUPT GOTO ISR
            PR2 = 124   ' load period register for 2mSec 
            PEIE = 1    ' Enable peripheral interupt
            GIE = 1     ' enable Global interrupt
            TMR2ON = 1  ' TMR2 ON
            GOTO LOOP                
    
            disable
    ISR:
            TOGGLE PORTB.0
            TMR2IF = 0  ' Clear interrupt flag
            resume
            enable
    // end snip
    Last edited by mister_e; - 30th December 2007 at 21:26.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    thanks, i just found it myself.

    4000000/4/256/16/2=122
    osc/4/8bit/precaler/postprescaler=period
    1/122=0,008S

    4000000/4/256/16/4=61
    1/61=0,016S

    now try at the code..

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


    Did you find this post helpful? Yes | No

    Default

    or... easier way... PICMultiCalc, Timer Helper.
    http://www.mister-e.org/pages/utilitiespag.html

    255-Value listed in the list, and you're in business

    Raise your hand those using it.. at least for timer!!!

    OK Darrel
    Last edited by mister_e; - 30th December 2007 at 22:50.
    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

    Well, I can use the timer now.
    I even added a postscale of 1:16 and a prescale of 1:16 so it's interrupt-frequency was about 15Hz. The segments were blinkin visibly. Even then, when I changed 'resume loop' to 'resume' I had no changing data to my display. Only the var's he already had.

    So, somehow there is something wrong with the resume command. And I really don't know what it is...

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


    Did you find this post helpful? Yes | No

    Default

    Nah there's no issue with RESUME... i'm trying to analyze the whole program here. yeah i TRY.

    Try something... comment out the whole none-ISR code, assign a value to the var used in your ISR, and see if there's any problem. You main loop could be anything like a LED blink. Careful with your delays... you're using ON INTERRUPT...

    EDIT:
    found 2 X 74HC595 on a really old board here, need to test them first...
    Last edited by mister_e; - 31st December 2007 at 00:06.
    Steve

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

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

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