Can not change variable while using DT_INT?


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2013
    Posts
    4

    Default Can not change variable while using DT_INT?

    Hi All,

    I'm using DT_INTS-14 with the 16F887. The idea is to run the device as a variable PW/FREQ oscillator. I then interrupt that loop to change it's variables. However, when I change the variables it's like nothing ever happened, even though the inputs have been verified functional (LEDs, scope, etc.) Is this happening because DT_INTS is storing then reloading ALL the data each time it interrupts? If so, how do I get around this?

    The code goes something like this:

    asm
    INT_LIST macro
    INT_Handler RBC_INT, _Change, PBP, yes
    endm
    INT_CREATE
    endasm
    @ INT_ENABLE RBC_INT

    Oscloop:
    high portd.1
    pauseus ontime
    low portd.1
    pauseus offtime
    goto oscloop

    Change:
    if portc.0=1 and ontime<1000 then ontime=ontime+1
    if portc.1=1 and ontime>10 then ontime=ontime-1
    if portc.2=1 and offtime<10000 then offtime=offtime+10
    if portc.3=1 and offtime>1210 then offtime=offtime-10
    pause 100

    @ INT_RETURN

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Default Re: Can not change variable while using DT_INT?

    Hi,

    Difficult to give a precise answer with such a " code scheme " ...

    the thing is ... with DTinterruptions, you save vars BEFORE interrrupt and restore them when returning ...
    so, considering this detail, what happens looks obvious.

    May be you should have a look here http://darreltaylor.com/DT_INTS-14/elapsed.html to see how button changes are held ...


    Alain
    Last edited by Acetronics2; - 28th March 2013 at 10:37.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Mar 2013
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Re: Can not change variable while using DT_INT?

    I looked at that example and I don't see how I can alter a variable while in the interrupt routine. I've tried to write the variable to memory then read it back after exiting the interrupt but that proved to be a very slow approach. Surely I'm missing something simple here, what good is an interrupt if I can't use variables with it!?

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Can not change variable while using DT_INT?

    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Mar 2013
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Re: Can not change variable while using DT_INT?

    Thanks for taking a look at this guys. I read through everything on Davids page but I'm making not progress. I need to establish variables in my main program, then, when the interrupt occurs, change those variables. I'm not seeing a good way to do this at the moment since, as was pointed out, the variables are saved then recalled after the interrupt, effectively bypassing any change made during the interrupt.

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


    Did you find this post helpful? Yes | No

    Default Re: Can not change variable while using DT_INT?

    User variables are not saved and restored for the interrupts. Only PBP's SYSTEM variables are.

    But PORTB Change Interrupts (RBC_INT) only work on PORTB.4-7 on the 16F887.
    You are testing PORTC pins in the ISR.
    DT

  7. #7
    Join Date
    Mar 2013
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Re: Can not change variable while using DT_INT?

    Thanks Darrel. I tried this:

    asm
    INT_LIST macro
    INT_Handler RBC_INT, _Change, PBP, yes
    endm
    INT_CREATE
    endasm
    @ INT_ENABLE RBC_INT

    Oscloop:
    high portd.1
    pauseus ontime
    low portd.1
    pauseus offtime
    goto oscloop

    Change:
    portd.0=1
    if portb.4=1 and ontime<1000 then ontime=ontime+1
    if portb.5=1 and ontime>10 then ontime=ontime-1
    if portb.6=1 and offtime<10000 then offtime=offtime+10
    if portb.7=1 and offtime>1210 then offtime=offtime-10
    @ INT_RETURN


    The above works well. The thing is, with the original program, I was triggering the int with a rising edge on portb.0 then sending the necessary change bit over portc.0-3. The timing was generous, portb.0=1 for 100ms (not that this matters as it should have been a rising edge trigger anyway) then which ever ever portc was active was held high for 100ms as well. The timing was verified with a scope, as was entrance into the change routine by the ISR. Why did that not work?

    Thanks again!

Similar Threads

  1. Change a variable to the opposite?
    By Hylan in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 21st June 2012, 08:00
  2. Change variable allocation to save code space
    By aberco in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 5th September 2011, 02:28
  3. Question on DT_INT
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 26th July 2011, 16:04
  4. A little DT_INT confusion.
    By circuitpro in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th October 2010, 01:46
  5. Let a variable change from bin to dec.
    By Roy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 25th May 2004, 20:57

Members who have read this thread : 1

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