Jump to content
David_P

I2C interfacing with 8-bit(s)

Recommended Posts

Anyone have any experience in interfacing I2C ICs to an Atari 8-bit? I'm looking at the joystick ports vice SIO for simplicity.

 

In addition, I2C is supposed to be a multi-master bus; that would suggest it should be possible to share any I2C peripheral between two or more 8-bits.

Share this post


Link to post
Share on other sites

No. Although years ago I developed inter-system comms between A8-> C64 (A8 joysticks to C64 serial) and A8-> Atari ST, which was an APE-like emulator which used A8 serial and no extra software required, to ST parallel with the ST running the emulation layer.

 

Just looking at the Wiki article - I2C seems to be a little different from SIO in that it leaves the clock line high after transmission.

 

On the Atari:

- the clock line is only used in certain SIO modes. The Atari OS uses a mode where the clock is generated/transmitted by Pokey.

- data bits are sampled when clock goes low, and change when it goes high. I2C appears to do the opposite.

Share this post


Link to post
Share on other sites
- data bits are sampled when clock goes low, and change when it goes high. I2C appears to do the opposite.

 

To send a bit of data as master, a device should assert clock, drive the bit, release clock, and wait for the clock wire to go high.

 

A receiving slave device that sees the clock wire go low should hold the clock wire low until it has a chance to process the bit.

 

If the master waits for the clock wire to go high after each bit, and if the slave has some hardware to latch the clock line low and do a few other things, it won't matter if the slave CPU is sometimes 'distracted' with interrupts, badlines, etc.

 

Note that many slave devices never hold clock low, and so some software I2C master implementations don't check for it.

Share this post


Link to post
Share on other sites

Thanks for the quick replies. I'm looking at bit twiddling on a joystick port, and possibly going to two lines on the Atari (data in and data out) - use two bits on the port, a diode on each to keep things unidirectional.

Share this post


Link to post
Share on other sites

You could use an invertor IC to take care of the clock problem.

 

I don't know if the Atari would support a device pulling it's own values on the clock line, although there is mention of bi-directional clock modes.

 

If the bps rate is a known value, the Atari can supposedly work in unclocked mode anyway and will resync. It should work fine so far as you're within +- 5%

Share this post


Link to post
Share on other sites

Hello David

 

Guus Assmann has drawn a schematic year ago, for an I2C interface that connects to the joystickport(s). It's really simple. If I don't forget, I'll see if I can find it this evening.

 

greetings

 

Mathy

Share this post


Link to post
Share on other sites
Guus Assmann has drawn a schematic year ago, for an I2C interface that connects to the joystickport(s).

And I implemented a simple I2C stack to use it :-)

 

The interface is really simple: Just use 2 pins of a joystick port for SDA/SCL, connect pull-up resistors (10k or 4k7 are fine) and you are done.

 

Here's a link to my software: http://www.horus.com/~hias/tmp/atari-i2c-0.11.zip

 

Have a look at the README.TXT, i2c.inc and i2c.src files. I also included some demo applications to show how to interface to a I2C RTC from assembler and basic.

 

so long,

 

Hias

Share this post


Link to post
Share on other sites

Thanks! Excellent work. I found an online vendor selling I2C boards for around $8 each for both a battery-backed RTC and a flash drive - ships with 16K, easily upgradeable to 256K by swapping out the ICs. (www.futurlec.com - slow shipping, but it's to be expected when it comes from half way around the world). I'm looking at writing a Z: driver for the RTC (DS1307), and possibly a disk handler (128 byte sectors) for the remainder.

 

More to follow as time permits...

Share this post


Link to post
Share on other sites

Hello Dan

 

That's the nice thing about I2C. It doesn't really have a fixed speed. Just a maximum speed. Which has been increased over the years.

 

greetings

 

Mathy

Share this post


Link to post
Share on other sites

I've heard of people doing somewhere around 100,000 kbps via the joystick ports.

 

Regardless of what you might achieve with nice shielded wiring, twisted pairs, whatever - you're constrained by the CPU.

 

100,000 bps means about 18 cycles per bit - if you turn the screen off.

 

I guess a heavily optimised I/O routine could use tables to avoid having to do bitshifts, which might reduce the overhead. But still, bit banging means that at really high speeds you then have to contend with Refresh DMAs causing the interval between bits to fluctuate.

Edited by Rybags

Share this post


Link to post
Share on other sites
Hello David

 

Guus Assmann has drawn a schematic year ago, for an I2C interface that connects to the joystickport(s). It's really simple. If I don't forget, I'll see if I can find it this evening.

 

greetings

 

Mathy

 

/Necrobump

 

Does anyone know where this schematic is?

Share this post


Link to post
Share on other sites
Does anyone know where this schematic is?

If found it in my mailbox. The PCF 8583 is the RTC, the 24C16 is a serial EEPROM (just for testing if this also works).

 

IICKLOK.pdf

so long,

 

Hias

Share this post


Link to post
Share on other sites

And I implemented a simple I2C stack to use it :-)

 

The interface is really simple: Just use 2 pins of a joystick port for SDA/SCL, connect pull-up resistors (10k or 4k7 are fine) and you are done.

 

Here's a link to my software: http://www.horus.com...ri-i2c-0.11.zip

 

Have a look at the README.TXT, i2c.inc and i2c.src files. I also included some demo applications to show how to interface to a I2C RTC from assembler and basic.

 

so long,

 

Hias

Hi, Hias (and all).

 

Sorry to revive an old thread but while looking into RTCs I came across many low cost Arduino modules like this one and of course this thread.. Would one of these RTC modules work here?

 

-SteveS

Share this post


Link to post
Share on other sites

Sorry to revive an old thread but while looking into RTCs I came across many low cost Arduino modules like this one and of course this thread.. Would one of these RTC modules work here?

The module looks fine and I guess it should work.

 

Of course you'd have to modify the source code and change the I2C address and registers (which are different to the PCF I used in my example code).

 

so long,

 

Hias

Share this post


Link to post
Share on other sites

The module looks fine and I guess it should work.

 

Of course you'd have to modify the source code and change the I2C address and registers (which are different to the PCF I used in my example code).

 

so long,

 

Hias

Ah, of course.

 

I'll give it a try.

 

Thanks, Hias!

Share this post


Link to post
Share on other sites

I have hooked up an ARDUINO board with DS1307 RTC right to the PIA (PA0 and PA1 are used) That works great.

 

It did not work out of the box connected directy to the Joystick Port.

 

I have contacted Guus Assmann about that, but his advice did not help me yet.

 

My problem is that the RTC works great connected to the PIA, and using PA0 and PA1 is rather safe to do (you still can use your joystick since that can not alter PA0 and PA1 at the same time!) But ... as soon as you connect a Touch Tablet (which still leaves Pa0 and PA1 alone) the RTC does not work anymore.

 

I still don't understand completely how that can happen. The RTC is soldered almost directly on the PIA and still... when something is connected on the joystick port; even when PA0 and PA1 aren't even touched... there is something that makes that the RTC can not communicate well with the PIA.

Share this post


Link to post
Share on other sites

Hi,

 

two things... maybe the TouchTablet pulls one of pins (PA0, PA1) to ground or VCC (+5 volts). Also if there is a low-valued resistors this may happen. Check with DMM.

 

When this problem occours after the software for TouchTablet is loaded, then the software may change the DDRA (Data Direction of port A) in any interrupt or so. Some RS232 interfaces for the joystickports also work in this way. Use monitor or Freezer to find it out.

 

Jurgen

Share this post


Link to post
Share on other sites

Hi Jurgen,

 

Thanks for your reply. Unfortunately nothing of this all does happen. The problems do occur as soon as I connect the touch tablet; so no software problem. It have measured with DMM, nothing weird is going on. It think I will open up the touchtablet to check what is going on inside.

 

For my own solution: I now connect touchtable to joystick port 2 in stead of joystick port 1, and I adapted atari Artist, so I can work with it; so problem is solved a bit.. but ofcourse I would like that my RTC 'invention' is as compatible as possible.

Share this post


Link to post
Share on other sites

I have hooked up an ARDUINO board with DS1307 RTC right to the PIA (PA0 and PA1 are used) That works great.

 

It did not work out of the box connected directy to the Joystick Port.

 

I have contacted Guus Assmann about that, but his advice did not help me yet.

 

My problem is that the RTC works great connected to the PIA, and using PA0 and PA1 is rather safe to do (you still can use your joystick since that can not alter PA0 and PA1 at the same time!) But ... as soon as you connect a Touch Tablet (which still leaves Pa0 and PA1 alone) the RTC does not work anymore.

 

I still don't understand completely how that can happen. The RTC is soldered almost directly on the PIA and still... when something is connected on the joystick port; even when PA0 and PA1 aren't even touched... there is something that makes that the RTC can not communicate well with the PIA.

well, I ordered an RTC module (a different one than my link showed).

 

My controllers are joysticks, paddles, and a mouse (but that's on joy2). No touch tablet. Hopefully, I won't have a problem. Might even be a non-issue for me. I can't imagining accessing the RTC more than once per session (SDX) and I don't typically use game controllers at such times.

 

-SteveS

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...