problem using GOSUB under interrupt


Results 1 to 11 of 11

Threaded View

  1. #1
    Join Date
    Apr 2009
    Posts
    6

    Default problem using GOSUB under interrupt

    Hello Guys,

    It is the first time I post a message here and I hope somebody could give me some suggestion.

    Here my problem:

    In my PBP program I'm using the ON INTERRUPT statement to activate interrupt.

    The interrupt routine is basiccally a decoding routine for a IR wireless communication which grab data from the IR signal and stores them into some variables.
    eahc time a correct value is received, it is stored into the variable and the interrupt calls, using GOSUB, a subroutine which reproduce a sound controlling an external chip.

    So the problem is here. The audio reproduction routine uses some delay cycles and is wrote under the DISABLE/ENABLE statement, in other words it could not be afected by the interrupts itself.
    It is something like this:

    ------------------------------------------------------
    DISABLE
    audio out:
    HIGH reset
    PAUSE 5
    LOW reset
    PAUSE 10
    HIGH data
    PAUSE 5
    LOW data
    data_count=8
    next_bit
    IF sound_code.0 = 0 then
    HIGH data
    PAUSEUS 200
    LOW data
    PAUSEUS 400
    ELSE
    HIGH data
    PAUSEUS 400
    LOW data
    PAUSEUS 200
    ENDIF
    sound_code=sound_code>>1
    data_count=data_count-1
    IF data_count > 0 THEN next_bit
    RETURN
    ENABLE

    ------------------------------------------------------

    As you can see it produces a timed signal to send to the audio device a serial command.

    The problem exactly is:

    If I call this sub from the interrupt routine like it is, it didn't make the pauses... if inside the audio_out routine I put a GOSUB which calls a sub which is outside the DISABLE/ENABLE statement, it works. So, to have the pauses working I must do something like this:

    ------------------------------------------------------

    DISABLE
    audio out:
    GOSUB do_nothing
    HIGH reset
    PAUSE 5
    LOW reset
    PAUSE 10
    HIGH data
    PAUSE 5
    LOW data
    data_count=8
    next_bit
    IF sound_code.0 = 0 then
    HIGH data
    PAUSEUS 200
    LOW data
    PAUSEUS 400
    ELSE
    HIGH data
    PAUSEUS 400
    LOW data
    PAUSEUS 200
    ENDIF
    sound_code=sound_code>>1
    data_count=data_count-1
    IF data_count > 0 THEN next_bit
    RETURN
    ENABLE

    do_nothing:
    RETURN

    ------------------------------------------------------

    In the reality the pauses are made by a ASM delay routine but the problem is present also if I use the PAUSEUS and PAUSE statement.

    Any idea?

    Thks in advance
    Last edited by fobya71; - 5th March 2010 at 08:52.

Similar Threads

  1. Graphic LCD with PICbasic pro
    By amindzo in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th November 2012, 11:45
  2. shifting problem
    By helmut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st August 2007, 06:11
  3. Controlling an 240x128 LCD Touchpanel Display
    By Vincent in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 7th June 2006, 23:36
  4. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 20:10
  5. ds1307 from f877 to f452 not work
    By microkam in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th July 2005, 00:02

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