Path: utzoo!attcan!uunet!mcsun!hp4nl!phigate!cnps!news From: jpexg@wheaties.ai.mit.edu (John Purbrick) Newsgroups: comp.sys.atari.st.tech Subject: Re: Cartridge Port Message-ID: <1171@cnps.PHILIPS.nl> Date: 23 Jul 90 12:38:16 GMT Sender: news@cnps.PHILIPS.nl Lines: 43 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