I2C Interface of a CB2, PB7

Topics related to the SBC- series of printed circuit boards, designed by Daryl Rictor and popular with many 6502.org visitors.
Post Reply
diyhouse
Posts: 8
Joined: 02 Jan 2011
Location: UK
Contact:

I2C Interface of a CB2, PB7

Post by diyhouse »

Did anyone write an I2C interface using the CB2 and one data line of the 6522, using a "bit-bang" technque.

Rather than re-invent the wheel I was wondering if this was already done somewhere out there, and save me some learning effort.

many thanks

Mark
Last edited by diyhouse on Tue Nov 08, 2011 10:48 am, edited 1 time in total.
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Post by GARTHWILSON »

I use CB2 for the I²C clock on my workbench computer, and PB7 for the data. Using bit 7 for data works well for reading data because you can just branch on whether the byte is negative or not without ANDing-out a bit. You put a pull-up resistor on the port, set the output bit to always 0, then make the pin an input (with the data direction register) for reading data and an output only for pulling the line down. (Outputting a 1 is automatic if you leave the pin in input mode since the resistor pulls it up.)

I'm not using the pull-up on the clock line, but I will next time, not particularly for being able to have multiple controllers, but I understand that a few I²C devices hold the clock line down when they're not ready for more data. I have not encountered any such ICs yet, and I probably won't be going too fast by just bit-banging, and the I²C ICs I've used have software handshaking anyway with the ACK bit, reading a status register, etc..

If you do put the clock line on PA or PB, it works best to have it as bit 0, so you can put a positive pulse on the line for example with just INC DEC, just two instructions (assuming you have already set the bit low beforehand so you know you won't mess up the other bits).

I found my code for it but I'll have to do some translating into assembly since it's mosly in Forth. I can't take the time at the moment.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
diyhouse
Posts: 8
Joined: 02 Jan 2011
Location: UK
Contact:

Post by diyhouse »

Garth,.. Very great full,.. do you have an outlook as to when you might be able to do the conversion stuff,... I've got plenty of other things to do,.. I can just plan what to do next.

thanks
mark
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Post by GARTHWILSON »

You and Daryl have email. Let me know if it came through correctly.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re:

Post by GARTHWILSON »

diyhouse wrote:
Garth,.. Very great full,.. do you have an outlook as to when you might be able to do the conversion stuff,... I've got plenty of other things to do,.. I can just plan what to do next.
There's an I²C interface in the "Interfacing to I²C" section of the potpourri page of my 6502 primer, and I just posted working 65c02 assembly-language code to go with it, at http://wilsonminesco.com/6502primer/GENRLI2C.ASM. Hopefully I got all the special DOS/ANSI [Edit: that should say IBM437] characters out of it (like ², µ, ±, etc.).
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
User avatar
BigDumbDinosaur
Posts: 9427
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Re:

Post by BigDumbDinosaur »

GARTHWILSON wrote:
...and I just posted working 65c02 assembly-language code to go with it, at http://wilsonminesco.com/6502primer/GENRLI2C.ASM. Hopefully I got all the special DOS/ANSI characters out of it (like ², µ, ±, etc.).

Note the
65C02 part. The code as written won't work with an NMOS MPU due to the use of TRB, TSB, etc.

As far as the DOS/ANSI characters go, I didn't see any, at least in the assembly language parts (I didn't peruse the Forth sections).
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: I2C Interface of a CB2, PB7

Post by GARTHWILSON »

Yes, 65C02, which I strongly encourage in the primer since the reader is building new hardware. I wish the GUIs kept the DOS/ANSI [Edit: that should say IBM437] character set, because it is really nice for putting timing diagrams right in the source code, without .jpg's or anything that would make the assembler choke. Special characters too.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
User avatar
BigDumbDinosaur
Posts: 9427
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: I2C Interface of a CB2, PB7

Post by BigDumbDinosaur »

GARTHWILSON wrote:
Yes, 65C02, which I strongly encourage in the primer since the reader is building new hardware. I wish the GUIs kept the DOS/ANSI character set, because it is really nice for putting timing diagrams right in the source code, without .jpg's or anything that would make the assembler choke. Special characters too.

The source code editor in the Kowalski simulator will accept the DOS/ANSI characters.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
Post Reply