Page 1 of 1

IRQ stuff and things (macptr)....

Posted: Mon Aug 07, 2023 8:12 am
by badmai
I'm trying to understand what is going on, yeah I could study the rom code...but maybe someone can help.

The example I uploaded, sets an IRQ to load more sound data for the AFLOW interupt using the macptr....

this works while I just infinate loop the "main" code, but what is going on when returning to basic?
in theory, it should load more audio data as needed from IRQ.

is macptr not usable in an interupt?

upload contains "WORK.PRG", "NOWORK.PRG", and sdcard....
*warning - NOWORK.PRG causes static noise!!! - headphone warning!!


this is in Prog8...
working:

Code: Select all

    sub start() { 
        
        stream_audio()
        repeat {}
    }
Not working:

Code: Select all

    sub start() { 
        
        stream_audio()
        ; repeat {}
    }

Thanks

Re: IRQ stuff and things (macptr)....

Posted: Mon Aug 07, 2023 4:48 pm
by desertfish
MACPTR can probably be used from an IRQ if you make sure the registers are properly saved, the correct ROM bank is set, etc etc.
But it is probably better to let the IRQ handler finish its task as quickly as possible and signal the main program loop that a new piece of data should be loaded. You can do this by setting a flag (or sometimes called a "semaphore") in the IRQ handler that is checked in the main program loop. If it's set the loop does the task and resets the flag.
You're using prog8 - checkout the cx16/pcmaudio/stream-wav.p8 example that does the above.