[comp.sys.atari.st.tech] Save--Use--Restore MFP timers, help wanted.

fk@vall.dsv.su.se (Fredrik Kilander) (11/22/90)

	Hello NetPeople and NetBeings.

	I`d come across a question which I`d be happy if you would
	discuss with me. I`ve begun to suspect that there is no easy
	solution to the problem behind it.

	IN SHORT: is there a canonical, clean and Officially Approved
	way of restoring the Timer Data Registers in the MFP MC68901
	to either the values they where initialised with before my
	program touched them, or their initial, reset values?

	I am working on a program (real-time audio pitch converter) in
	which I need two timers. The documentation I have describe
	the MFP`s timers like this:

		Timer A: applications and end-users
		Timer B: horizontal blank counter
		Timer C: System clock 200 Hz
		Timer D: RS232 baud rate

	Timer A is of course available. I hope that timer D can be restored
	by reading and restoring the RS232 configuration via TOS.
	Timer B is an enigma. Does it count pulses or does it generate them?
	If it generates them, would using timer B cause problems (like
	frying the monitor?). Timer C runs at 200 Hz and I guess this is
	equal for most ST`s and MEGA`s; it could be restored by simply
	set to run at that frequency.	

	I also speculate that reading the Timer Data Registers (TADR, TBDR, 
	TCDR, TDDR) is pointless, since they contain not the initialization
	values but the current timer count. Reading and restoring the other
	registers (Interrupt Enable Reg., Interrupt Mask Reg, Vector Reg. 
	and the three control registers) are probably alright. The
	application acquires the total execution context while using the
	timers (IPL 5, only timer interrupts allowed).

	The simple way out is of course to do like a game: you can't exit
	unless the computer is reset. But I`d rather be able to use and
	restore the MFP at will, without horrible side-effects.

	So, to sum up my questions:

	- What is the usage and initial settings of timer B?

	- Is there a clean way to obtain and restore the Timer Data Regs.?


	I will be happy for every comment and reply, email preferred. Any
	scrap of trivia, pointers to documentation or previous postings
	is welcome. A summary will follow the resolution of the problem.

	BTW: the pitch converter works, the problem arises when it is time
	to clean up and leave. Those of you who are interested can have
	source and binary in jas assembler and Sozobon C. You`d also need
	the Replay cartridge (the old one, with one input and one output)
	from Microdeal. Routines for other samplers could very likely be 
	fitted as well. The program also does echoing, but that
	needs only one timer.

	Fredrik Kilander, fk@dsv.su.se.


-- 
===============================================================================
 Fredrik Kilander, Dpt. of Computer and Systems Sciences, Stockholm University
 Internet: fk@dsv.su.se Voice: +46 8 16 45 00 Fax: +46 8 703 90 25
===============================================================================