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.
User avatar
Badger
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

I2C for the Oric

Post by Badger »

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 8933 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
Wing Commander
Posts: 1641
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: I2C for the Oric

Post by iss »

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
2nd Star Corporal
Posts: 31
Joined: Sun Jan 05, 2020 2:38 pm
Location: Leicester, UK

Re: I2C for the Oric

Post by DigitalDunc »

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
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger »

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: 3014
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: I2C for the Oric

Post by Chema »

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
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger »

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
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger »

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.
User avatar
Badger
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger »

Major success.

I now have an I2C real time clock module running on actual Oric Hardware :D
oricrtc2.jpg
oricrtc2.jpg (169.48 KiB) Viewed 8742 times
Source files can be found at https://github.com/BadgeOric/OricI2C.git with the i2ccombi file being the assembly source which contains 2 routines.

At $4000 the main get data from the I2C module and at $4165 display time on status line.

For ease of testing I packed this code into data statements and used some Basic code for loading and generating test reults.

The i2c module is connected to the atmos via the printer port with the SDA pin connecting to Pin 3 of printer port (bottom row, 2nd pin from left looking from the back), CLK connecting to Pin 5 of printer port (bottom row, 3rd pin from left) and gnd going to any pin on the top row. +5v to the rtc module could be taken from the expansion port , but I didnt on this case as I used a battery to power the I2C module (4.5v).
oricrtc1.jpg
oricrtc1.jpg (158.51 KiB) Viewed 8742 times
The basic code has 3 routines. lines 1-9999 are setting up the assembly routines.

10000-10200 one shot get time from RTC. Also sets up the zero page addresses required for reading the module.

20000 - 20030 continuous update every 2 seconds. Cant do anything else with the oric, just a proof of concept :)

In theory the code at $4000-$4164 could be used with any I2C module if the zero page are set. So here they are

RxBuffL = $00 ; receive buffer pointer low byte - I used $6000 so set this to $00
TxBuffL = RxBuffL
RxBuffH = $01 ; receive buffer pointer high byte- I used $6000 so set this to $60
TxBuffH = RxBuffH
ByteBuff = $02 ; byte buffer for Tx/Rx routines - no setting needed
I2cCountL = $03 ; Tx/Rx byte count low byte - count of bytes to send/receive
I2cCountH = $04 ; Tx/Rx byte count high byte - Always set to 0, limit to 255 bytes in send/receive buffer
RWFlag = $05 ; 0 or 1 (0 = send data from buffer, 1= receive data to buffer)
OldPCR = $06 ; temp store for via pcr - no need to change
DevAddress = $07 ; I2C address - $68 for 1307 rtc module
I2CPort = $301 ; 6522 Via Output Register Port A no need to change
ViaDDRA = I2CPort+2 ; 6522 Via Data Direction Register Port A - no need to change
ViaPCR = I2CPort+12 ; Preipeheral Control Register to Diable AY chip - no need to change

The TAP file is attached as well as on github.

Hope some find it useful :)
Ian
Attachments
Orici2c.tap
(2.43 KiB) Downloaded 269 times
flag_uk Amateurs built the Ark, Professionals built the Titanic.
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: I2C for the Oric

Post by Dbug »

Can this i2c thingamagic be somewhat used to add TCP/IP/Ethernet support to the Oric?
User avatar
Badger
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger »

Dbug wrote: Sun Jan 26, 2020 12:38 pm Can this i2c thingamagic be somewhat used to add TCP/IP/Ethernet support to the Oric?
In theory yes. If there is a module I2C to Ethernet then almost certainly. If an existing module doesnt exist already then one could possiblyt be made but that is probably beyond my skills.

It would be rather slow but still faster than nothing.

I'll have a look around as a quick look finds something , but its for sending data over ethernet rather than implementing tcp/ip.

An incomplete list of devices is available at https://learn.adafruit.com/i2c-addresses/the-list.

I have on order (hope to arrive this week) a 0.3megapixel camera, a 16kb static ram module and a gyroscope/accelerometer module.

For my next project , I would like to try to implement the SPI protocol using a similar method. This probably has more chance of being used for ethernet as I think some exisitng raspberry pi and arduino modules already exist.

As an added bonus :D I have attached the tap file for a hires analogue clockface using the rtc module. Its in basic with the I2C protocol assembly code embeded in data statements code and is actually a modified version of the the lisitng found in the book Meteoric Programming.
It will display without an attached module, but oviously no data will be retriieved, so will stick at 12:00:00. This is useful though as it shows that if a module disconects for any reason , then the computer doesnt hang.

Regards
Ian
Attachments
clocky.tap
(3.42 KiB) Downloaded 271 times
flag_uk Amateurs built the Ark, Professionals built the Titanic.
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: I2C for the Oric

Post by Dbug »

For my next project , I would like to try to implement the SPI protocol using a similar method. This probably has more chance of being used for ethernet as I think some exisitng raspberry pi and arduino modules already exist.
I guess something like that: https://store.arduino.cc/arduino-ethernet-shield-2
User avatar
ibisum
Wing Commander
Posts: 1646
Joined: Fri Apr 03, 2009 8:56 am
Location: Vienna, Austria
Contact:

Re: I2C for the Oric

Post by ibisum »

Would love to see an ESP8266 or ESP32 wired up to do Wifi .. would this be feasible now?
User avatar
HigashiJun
Flying Officer
Posts: 205
Joined: Tue Dec 10, 2019 9:29 am
Location: Tokyo (Japan)

Re: I2C for the Oric

Post by HigashiJun »

Very interesting post...

I wonder if it's possible to have a RTC inside the Oric, which would be a neat solution.

Wouldn't pass-through RTCs like Dallas DS1216E run in our machines ?

Image

Your comments and ideas are welcome.

Cheers.
HigashiJun
User avatar
Badger
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger »

HigashiJun wrote: Tue Jan 28, 2020 1:41 pm
Wouldn't pass-through RTCs like Dallas DS1216E run in our machines ?
They could work in an oric, but you'd still need some code to read the time.
A couple of disadvantages I can think of are :-

No longer manufactured (I dont know if there is a replacement) so would rely on Ebay etc for supplies and is more expensive than the I2C module equivalent.

Would need to open the Oric to fit and I dont know if there would be enough clearance inside the case for the extra height. I dont think we need to worry about voiding the warranty though :D

Would need bespoke code to read the time whereas the I2C modules uses a defined standard protocol for data across any module you care to fit.

They also have a battery which at some point would need replacing. Harder to do with an internal module rather than external.

Having said all that, there is no reason I can see that it wouldnt work , and its an interesting scheme they came up with to be able to read and write to the device by reading rom addresses in a certain order.

A quick update on my module testing is that I now have the RTC fully functioning and testing an LCD display connected to the same I2C bus. If that works then it will proove that both data read/writes are working as they should.

Next step is see if it is possible to use an Arduino of some description to to act as a go between I2C on the Oric and USB on a PC. That could pave the way for an initial way of getting file tranfers from PC->Oric and even Net connectivity. Thats still a way off though.

I'll keep plodding along :)

Ian
flag_uk Amateurs built the Ark, Professionals built the Titanic.
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: I2C for the Oric

Post by Dbug »

Badger wrote: Wed Jan 29, 2020 7:25 pm A quick update on my module testing is that I now have the RTC fully functioning and testing an LCD display connected to the same I2C bus. If that works then it will proove that both data read/writes are working as they should.

Next step is see if it is possible to use an Arduino of some description to to act as a go between I2C on the Oric and USB on a PC. That could pave the way for an initial way of getting file tranfers from PC->Oric and even Net connectivity. Thats still a way off though.
RTC+LCD+NET would be totally cool for development, exchanging files, etc...
Post Reply