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_bitIF 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  
------------------------------------------------------
 
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_bitIF 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  
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  
				
			
Bookmarks