User avatar
Grumpy Mike
Posts: 914
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

I2C Access

Thu Aug 02, 2012 8:02 am

Has anyone got an example of I2C access on the Pi.
I am running the latest Distro 24July and have tried:-
Tank's GPIO write SWRs with the top bit set, the documentation says it will access a MCP23017

The SYS"IIC_Control"

and the SYS"OP_IICOp"

I can't see any activity on the Pi's GPIO 0 & 1 lines ( the I2C lines ) on my scope.

Is this working yet?

User avatar
joan
Posts: 14264
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: I2C Access

Thu Aug 02, 2012 8:27 am

From a recent post (which I can't find now).

http://www.robot-electronics.co.uk/htm/ ... amples.htm

User avatar
Grumpy Mike
Posts: 914
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: I2C Access

Thu Aug 02, 2012 9:00 am

Thanks but these are examples of reading the I2C bus with C from Linux.
I am after examples of accessing the I2C bus from RISC OS.

User avatar
joan
Posts: 14264
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: I2C Access

Thu Aug 02, 2012 9:48 am

My bad :oops:

Didn't notice the forum.

tank
Posts: 64
Joined: Thu Dec 15, 2011 5:51 pm

Re: I2C Access

Thu Aug 02, 2012 5:19 pm

I2C on the Pi is not yet implemented. See https://www.riscosopen.org/forum/forums/9/topics/1086 and it seems it might be close.
The testing I've done is on the Beagle so far, but it should just work when the above is in the Pi ROM.
If you issue a *GPIOMachine from a command line it reports what type of device you are running on and if any MCP23017 GPIO extenders are fitted.

User avatar
Grumpy Mike
Posts: 914
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: I2C Access

Fri Aug 03, 2012 12:06 pm

Thanks for that.
I had come across that thread and it sounded like it was included and they were working on a single unified driver.
Anyway now I know it is not implemented I can stop trying to make it work.

I have an interface board, using a PCF8574 ( 8 I/O ) and a PCF895 ( 4 input A/D + 1 D/A) with a good looking user interface for the RISC desktop ready to go when I can find the I2C calls that work.

bri999
Posts: 9
Joined: Sat Jul 14, 2012 8:10 pm
Location: Swanage, UK
Contact: Website

Re: I2C Access

Fri Aug 03, 2012 12:38 pm

I have got I2C working using a third party library called quick2wire and have some code on http://briandorey.com/post/Raspberry-Pi ... ading.aspx for reading a Microchip ADC using python

User avatar
Grumpy Mike
Posts: 914
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: I2C Access

Fri Aug 03, 2012 1:01 pm

Thanks, but again this is not a RISC OS implementation it uses Python.

tank
Posts: 64
Joined: Thu Dec 15, 2011 5:51 pm

Re: I2C Access

Thu Aug 30, 2012 5:48 am

Grumpy Mike wrote:Thanks for that.
I had come across that thread and it sounded like it was included and they were working on a single unified driver.
Anyway now I know it is not implemented I can stop trying to make it work.

I have an interface board, using a PCF8574 ( 8 I/O ) and a PCF895 ( 4 input A/D + 1 D/A) with a good looking user interface for the RISC desktop ready to go when I can find the I2C calls that work.

The latest ROM should now include I2C.
https://www.riscosopen.org/viewer/revis ... 53009.html

User avatar
Grumpy Mike
Posts: 914
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: I2C Access

Thu Aug 30, 2012 8:23 am

Great, however when I follow the instructions here:- http://www.pilearn.com/Pages/Page1001.html
I still download the August 8th image.
What to I need to do to turn those files you linked to into an image?

Matt Harris
Posts: 6
Joined: Fri Dec 23, 2011 11:22 pm

Re: I2C Access

Thu Aug 30, 2012 11:16 am

You need to replace the ROM image with that from the RISC OS Open download page:

https://www.riscosopen.org/content/down ... r-zipfiles

specifically the RaspberryPi image:

https://www.riscosopen.org/zipfiles/mis ... 1346224993

It's easiest to do all the work from within RISC OS.

Open the root of the SD card and then shift double-click !Boot to open the !Boot application directory.

Within that is a DOS image file, Loader, which allows access to the FAT partition of the SD Card.

Within Loader are all the files for booting the Pi - replace the file 'riscos' (or 'riscos/img' - can't remember exactly as I'm doing this from memory) with that from the previously downloaded zip file. (Might be worth copying the original 'riscos' file so that things can be recovered on another machine if a problem occurs).

Shutdown & re-boot and you should now be running the latest ROM.

Best regards,

Matt H

tank
Posts: 64
Joined: Thu Dec 15, 2011 5:51 pm

Re: I2C Access

Sun Sep 02, 2012 6:05 pm

tank wrote:I2C on the Pi is not yet implemented. See https://www.riscosopen.org/forum/forums/9/topics/1086 and it seems it might be close.
The testing I've done is on the Beagle so far, but it should just work when the above is in the Pi ROM.
If you issue a *GPIOMachine from a command line it reports what type of device you are running on and if any MCP23017 GPIO extenders are fitted.
I have now tested this on the Raspberry Pi and all seems to work.
I have also updated the GPIO module to include the I2C on the Pi and have tested with 2 expanders fitted.
(Latest module from http://www.tankstage.co.uk/Software/GPIO.zip)

User avatar
Grumpy Mike
Posts: 914
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: I2C Access

Tue Sep 04, 2012 2:22 pm

Awesome, a wimp program written in 1995 to display the I/O from my I2C interface board now runs on the Raspberry Pi accessing the same board without any modification.

For the record December 1995 in Acorn Computing.

Thanks. :D
Attachments
I2CScreen3a.jpg
I2CScreen3a.jpg (61.82 KiB) Viewed 8208 times

User avatar
Grumpy Mike
Posts: 914
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: I2C Access

Tue Sep 04, 2012 2:54 pm

As you are limited on this forum to small images.
For a better resolution screen dump see:-
Image

at
http://www.flickr.com/photos/[email protected]/7930132790/

colin B
Posts: 119
Joined: Sun Mar 04, 2012 12:23 pm
Contact: Website

Re: I2C Access

Thu Sep 06, 2012 2:14 pm

Matt Harris wrote:
Within Loader are all the files for booting the Pi - replace the file 'riscos' (or 'riscos/img' - can't remember exactly as I'm doing this from memory) with that from the previously downloaded zip file. (Might be worth copying the original 'riscos' file so that things can be recovered on another machine if a problem occurs).
Should this always be done from within riscos? I copied the ROM image to the SD card from within Windows, renamed it from riscos to riscos.img, the Pi would not boot from this version. Should I have changed the riscosZZ.img as well?

I am using the 8th August image.

Colin
On a clear disk one can seek forever

Matt Harris
Posts: 6
Joined: Fri Dec 23, 2011 11:22 pm

Re: I2C Access

Thu Sep 06, 2012 3:19 pm

colin B wrote: Should this always be done from within riscos? I copied the ROM image to the SD card from within Windows, renamed it from riscos to riscos.img, the Pi would not boot from this version. Should I have changed the riscosZZ.img as well?

I am using the 8th August image.
Colin,

The riscosZZ.img is superfluous so is not really needed.

Doing this in Windows or RISC OS should give the same result, it's just I found it easier to do from within RISC OS.

How far are you getting in the boot process?

Are you just getting the multi-colour square (i.e. the GPU cannot find a 'kernel')?

If so, it is possible that the DOS 8.3 version of the 'riscos.img' file is not 'RISCOS.IMG' but something like 'RISCOS~1.IMG' thanks to the way long filenames and case sensitivity works in Windows.

From your Windows box, launch a command prompt window and then type the following command:

Code: Select all

C:\Users\[username]> dir F:\ /x
(where 'F:\' is the drive letter of your SD card)

This will provide a directory listing that will show, where different, the DOS 8.3 format filename.

If there is a difference shown, you will need to rename the file and then re-verify.

Hope this helps.

Matt H

colin B
Posts: 119
Joined: Sun Mar 04, 2012 12:23 pm
Contact: Website

Re: I2C Access

Fri Sep 07, 2012 6:07 am

Not sure what the problems, the SD card contents seemed OK, but I re-imaged it and copied the latest ROM across, and everything burst into life.

Now to persuade the system to display nicely on a 32'' TV!

Thanks for your help
On a clear disk one can seek forever

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: I2C Access

Mon Nov 19, 2012 3:51 pm

Hi

Can anypne point me to refreence materials on SYS"IIC_Control" and SYS"OP_IICOp" ?

Thanks

tank
Posts: 64
Joined: Thu Dec 15, 2011 5:51 pm

Re: I2C Access

Mon Nov 19, 2012 5:44 pm

pygmy_giant wrote:Hi

Can anypne point me to refreence materials on SYS"IIC_Control" and SYS"OP_IICOp" ?

Thanks

https://www.riscosopen.org/wiki/documen ... w/OS_IICOp

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: I2C Access

Tue Nov 20, 2012 12:30 pm

Thanks tank

I'm guessing that to use the I2C bus from C I need to populate the iic_transfer data structure described here: http://www.riscosopen.org/wiki/document ... c_transfer and then make a SWI call to OS_IICOp ?

Not sure how to go about that - I would be very grateful if you could provide me with a working example.

(I have gcc working under RISCOS and can successfully compile my robots' control system but it generates errors when run as the memory addressing method I previously used to access the I2C bus under Linux is no longer applicable.)

User avatar
Grumpy Mike
Posts: 914
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: I2C Access

Tue Nov 20, 2012 1:04 pm

Here are the simple ways of accessing I2C in RISC OS.
Attachments
RISCOS_I2C.zip
(1.38 KiB) Downloaded 336 times

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: I2C Access

Tue Nov 20, 2012 2:17 pm

thanks

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: I2C Access

Wed Nov 21, 2012 4:28 pm

...but I can only view the text in quotes - the rest is garbled. I have tried opening under RISCOS Strong Arm text editor.

Do I need to open these files with a specific application or view them with a specific character encoding?

User avatar
Grumpy Mike
Posts: 914
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: I2C Access

Wed Nov 21, 2012 4:47 pm

They were transferred direct from RISC OS onto an SD card. They were then placed on my Mac laptop where I zipped them up and posted them here.
.but I can only view the text in quotes - the rest is garbled.
They are RISC OS basic programs so the text in quotes will be the same but the code will be tokenised so you will have to use a RISC OS text editor that understands tokenised Basic programs, !Edit, !StrongArm or !Zap are amongst the editors that can view it.

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: I2C Access

Wed Nov 21, 2012 4:52 pm

Ummm.... not on my pi :?

Sorry to be a pain, but could you cut and paste the code into the forum's code tag?

:)

Return to “RISCOS”