I2C for the Oric

This is the right place to discuss on how to implement hardware vsync, adding a VIA or AY chipset, puting multiple roms, or how to design a new flash expansion card.
Post Reply
User avatar
Badger
Officer Cadet
Posts: 45
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

I2C for the Oric

Post by Badger » Sun Jan 12, 2020 10:02 am

Having recently completed (if it can ever be said to be completed).....I'll start again :D

Having recently got a working model of a 65C02 breadboard computer (picture attached) which contains an I2C interface on Port A of the 6522 via (bottom right chip).

Port B is a PS/2 keyboard. The I2c is connected to a 4 line LCD display.

Looking at info online, it seems that the printer port on the oric is connected to Port A of the via along with the AY-3-8912.

So would I be correct in assuming I could setup the printer port as an I2C interface with a modified version of the rom code (to be loaded into ram and possibly extending basic). With Port A of the via being bi-directional , it could be used for input as well as output. Could allow for LCD displays, real time clock, a multitude of sensors etc etc etc.

In the oric, the via is memory mapped so should be easy to talk to. Can switch between I2C and AY chip using the via control lines.

Before I start, am I missing something obvious which would prevent this from working?
Has anyone tried this before and hit a brick wall?

The rom code in the 65c02 only uses the PHX/PHY/PLX/PLY extra instructions which can easily be replicated in a macro so thats not an issue.

Building this has given me a great insight into the inner workings of 8 bit machines and the idea was to be able to transfer this knowledge across to the Oric amonst others.
6502bbc.jpg
6502bbc.jpg (308.53 KiB) Viewed 175 times
For those that are interested , the breadboard machine lookint at top left then going down the "column" of chips is
1) 29ee010 EEPROM (16Kb used out of 128k)
2) as6c400 Static Ram (32Kb available from 512k!!)
3) 65C02 processor - used for its ability to slow the clock and even manually single step.
4) 2nc 6522 Via (not connected)
2nd column
5) 74ls00 Quad 2 input nand gate - main part of memory glue logic
6) 74ls138 3 line to 8 line multiplexer - selection of via chips
7) 74ls04 - hex invertor and 1.8mhz crystal for the system clock.
8 68b50 Acia - for serial port connection - machine can run independant or with serial connection to pc .
9) 6522 VIA - with I2c connection (Port A left) and PS/2 keyboard connection (Port B right).

Other bits - 7805 voltage regulator, on./off swicth, reset button, 4 line 20 col i2c lcd display.

Rom image is modified collections from all over the internet but based around the 2014 retrochallenge rom monitor.

Hopefully this will become my next little project. :D
Ian
flag_uk Amateurs built the Ark, Professionals built the Titanic.

User avatar
iss
Squad Leader
Posts: 965
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: I2C for the Oric

Post by iss » Sun Jan 12, 2020 12:54 pm

This is crazy cool ... and working! Nice!
On your question: IMO, there should be no problem to use the Parallel port as I2C, but it depends how "Oric compatible" the whole thing should to be.

DigitalDunc
1st Star Corporal
Posts: 10
Joined: Sun Jan 05, 2020 2:38 pm
Location: Leicester, UK

Re: I2C for the Oric

Post by DigitalDunc » Wed Jan 15, 2020 8:42 pm

Of course you could use the printer port as an I2C interface. It’s worth pointing out that you _don’t_ need to replace the ROM image in any way to use it, though that does depend on how you plan to use your Oric. I would strongly recommend that you make the Oric the master not the slave however and be mindful that the NMOS 6522’s don’t have much of a drive capability by today’s standards.

Why don’t you consider using a uC as an intermediary, you’d get more exact I2C logic thresholds etc thrown in for free and lower the software overhead on the Oric side.

Do you have a cool idea to share?

User avatar
Badger
Officer Cadet
Posts: 45
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger » Wed Jan 15, 2020 10:38 pm

Thanks for the input and interest.

Yes, the oric would be an I2C master, and I was trying to avoid using a microcontroller if possible as for me its just experimentation and a proof of concept.

Currently I'm working on getting a DS1307 real time clock module working with some kind of analogue clock display just as a proof of concept. Once that is up and running any number of modules could be added. My first project would be to create some kind of environment monitoring.

Currently the i2c code would just about fit into page 4 of ram (so under basic) but will only know for sure once I get something working.

Could possibly even patch it into basic with the ! and have something like
10 !I2C(#68, 1, 0 , 7 , #6000) which would translate to read 7 bytes into memory location #6000 starting at device register address 0 , with device address #68). Changing the 1 to a 0 would make it a write7 bytes from memory etc etc.

I'm sure someone with more brains than me would be able to think of many things to do with it :D

Like with many things, real life gets in the way and the amount of time I can spend on it is limited so I wouldnt expect results too soon.
As soon as I do have something working I will gladly share the details and code.

Ian
flag_uk Amateurs built the Ark, Professionals built the Titanic.

User avatar
Chema
Game master
Posts: 2539
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: I2C for the Oric

Post by Chema » Wed Jan 15, 2020 11:22 pm

I must say I am deeply impressed by the amount, quality, and crazyness :wink: of the Oric projects that have appeared in the last months. Congratulations!

User avatar
Badger
Officer Cadet
Posts: 45
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger » Tue Jan 21, 2020 7:44 am

Ok first pass attempt at some code that should work on a real oric.

Using a DS1307 Real Time clock module.
The code is specific for that module at the moment.

Since I havent had a chance to make up a cable for the printer port yet, it is untested on a real Oric but does work on my breadboard 6502.

I have set the code with the Oric Via address ($301 for Port a) and used 5 ZP address that from what I can find are not used by basic (2B to 2F)

When testing I put the code at hex $4000 and the 7 byte send/receive buffer at $6000 for no reason that they seemed to be 2 out of the way locations.

If your already have a rtc module that is setup with date or time or have an arduino that can set it , then that is a easy way for now, although there is 5 lines that can be uncommented that will set a time and date with some randomly picked values that can be changed at the bottom of the listing.

A lot of the code is based on some I found at http://retro.hansotten.nl/6502-sbc/lee- ... -web-site/ but it didnt work out of the box so I modified to get something working, so may not be very efficient.

Printer port pin usage is commented in the code.

My next stage is to make a printer port connector (with the hard part getting the +5v from somewhere for the rtc module). I might decide that its easier to solder 4 wires to the VIA internally and pull it out of the TV port or similar.

After that its to modify the code to make it generically work with any I2C device.

Code can be found here :-
https://github.com/BadgeOric/OricI2C.git

Have fun
Ian
flag_uk Amateurs built the Ark, Professionals built the Titanic.

User avatar
Badger
Officer Cadet
Posts: 45
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger » Tue Jan 21, 2020 10:37 pm

Small update. Added a file to github that will display contents of clock buffer to the status line on the left hand side.

It does not auto update , would need to be called after getting the data from the RTC.

https://github.com/BadgeOric/OricI2C.git
flag_uk Amateurs built the Ark, Professionals built the Titanic.

Post Reply