Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!hp4nl!phigate!ehviea!leo From: leo@ehviea.ine.philips.nl (Leo de Wit) Newsgroups: comp.sys.atari.st.tech Subject: Re: Using Timer A to replay a sample Message-ID: <891@ehviea.ine.philips.nl> Date: 26 Sep 90 11:40:56 GMT References: <1990Sep24.122920.15704@irscscm.UUCP> Reply-To: leo@ehviea.UUCP (Leo de Wit) Organization: Philips I&E Eindhoven Lines: 51 In article <1990Sep24.122920.15704@irscscm.UUCP> mlake@irscscm.UUCP (Marshall Lake) writes: | |I have a programming problem and I'm hoping someone here can help me. | |I am attempting to play back a sample via timer A while allowing other |things to go on as it plays. When the program attempts to start the |actual playback it blows, sometimes displaying 4 bombs and sometimes |6. I have also tried to place the interrupt code into the main flow |of the program to see what would happen. The bombs don't occur but |nothing is emitted by the sound chip either. What am I doing wrong? [...] |do_snd () { | if (buff_cnt > buff_end) | return; | | snd_value = (*buff_cnt + 128) * 8;*/ | *sound_chip = snd_out[snd_value]; | *sound_chip = snd_out[snd_value + 4]; | | buff_cnt++; |} [...] |main () { [...] | Xbtimer (0, 7, 0, &do_snd); [...] |} Your do_snd routine must be coded as an interrupt routine; that is, it must end in a rte instruction; not only that, it must also mark (clear?) a bit in the I/O range (sorry, have to look this up), otherwise the system will think the interrupt is still pending (actually, I think the peripheral chip is thinking this 8-). For an example, take a peek into the ROMs to see how the system timer (timer C) is coded (the I/O address I mentioned is different, but you'll get the picture). Alternatively, you can do it the easy way, forget about programming it yourself and use the Xbios function Dosound() (but I assume there is a special reason you cannot use this?). And if you experience spurious interrupts using Xbtimer(), I got a solution for this too (8-). Cheers, Leo. P.S. The 4 bombs (illegal instruction) confirm that a wild jump was taken; this is because your code pops a return address off the stack where there is a status word and a return address.