[comp.sys.atari.st.tech] Cartridge Port

D.M.Johnson@newcastle.ac.uk (D.M. Johnson) (07/23/90)

        Could any one give me details of how to read data in through the
cartridge port. I know it must be possilbe, but the manual I have does not even
give pointers on how to do it. Any help will most useful. example code even
better. any langauge but Assemble, C or BASIC prefered.

Yours

Dave Johnson    D.M.Johnson@uk.ac.newcastle

jpexg@wheaties.ai.mit.edu (John Purbrick) (07/23/90)

In article <1990Jul20.104503.4504@newcastle.ac.uk> D.M.Johnson@newcastle.ac.uk (D.M. Johnson) writes:
>        Could any one give me details of how to read data in through the
>cartridge port. I know it must be possilbe, but the manual I have does not 
>even give pointers on how to do it. Any help will most useful. example code 
>even better. Any langauge but Assembly, C or BASIC prefered.

Very easy. Use the ROM3 and ROM4 lines (pins 31 and 33) as strobes to enable 16
bits in parallel onto the 16 data lines. NOTE THAT THE DATA LINES ARE NOT
INTERNALLY BUFFERED! If you put data on them at any time except when ROM3 or
ROM4 pull low, you will cause a big fat crash! 

Try this. It grabs 16 bytes in succession, then waits for data bit 8 to go 
high. When it does, the program knows that data are (grammar!) again
available and grabs another 16. A pulse on the ROM3 line alerts the sending
end of the system that a byte was grabbed, so it presents the next one. 
After 16 bytes, both parties should go back to the "inactive" state, with the
ST checking bit 8 to ensure that the cycle has ended, and another one begun.
ROM4 is only used to check for availability of the next data group. This
setup was used for testing a microprocessor-controlled tablet counting machine,
grabbing 16 bytes every 2 milliseconds. (Note: I may have inverted ROM3 and 
ROM4--but you should get the idea. Use a scope to figure them out.)

......
	carta = (int *)0xFA0000;		/* Rom3 */
	cartb = (int *)0xFB0000;		/* Rom4 */
	unsigned char *mem;

	mem = (unsigned char *)lmalloc(mem_size);

	for (mem_ptr = 0; mem_ptr < mem_size; mem_ptr += 16)
	{	do {raw = *cartb;} while (raw & 256);	/* Wait for low */
		while (!(raw & 256))		/* Wait for high */
			raw = *cartb;		/* Previous cycle must end */

		for (i = 0; i < 16; i++)
			*(mem + mem_ptr + i) = (unsigned char)*carta;
	}
......

Hope this helps!

John Purbrick
jpexg@ai.mit.edu

q1rse@turing.newcastle.ac.uk (D.M. Johnson) (09/19/90)

        I asked this question a few months ago a got some useful replys, I
however am still stuck,

        The plan for the cartridge port is this:
                I wish to read data from a video digister in to the computer
through the port, (The printer port is in use for something else) I understand
that the port should not be loaded with any data unless the rom select line is
pulled low, The question is this,
        How do I do it?    My C is not very good but I can understand it, any
help would be gratefully received, example even better,

Dave Johnson.

whitten@kuhub.cc.ukans.edu (11/11/90)

Does anyone know, well I know someone knows, but could someone tell me
how to toggle the ROM4 and ROM3 lines of the cart port?

I also will need to know how to put an address on the cart port lines,
and also read one.
 
Thanks,
Chris

==============================================================================
 WHITTEN@KUHUB.CC.UKANS.EDU              Chris Whittenburg, Univ. of Kansas
 WHITTEN@UKANVAX.bitnet                        Electrical Engineering
==============================================================================