more G-Labs products

Author Topic: Raspberry 2 MCP23017 Error  (Read 16634 times)

February 24, 2015, 10:22:16 PM
Reply #30

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
So if I fix this line:

https://github.com/genielabs/raspberry-sharp-io/blob/master/Raspberry.IO.InterIntegratedCircuit/I2cDriver.cs#L301
Code: [Select]
...
                case 3:
                    if (sdaPin == ProcessorPin.Pin2 && sclPin == ProcessorPin.Pin3)
                        return Board.Current.Model == '2' ? Interop.BCM2836_BSC1_BASE : Interop.BCM2835_BSC1_BASE;
                    throw new InvalidOperationException("No I2C device exist on the specified pins");
...
does it work?
Or also the base address here:

https://github.com/genielabs/raspberry-sharp-io/blob/master/Raspberry.IO.InterIntegratedCircuit/Interop.cs#L21

has to be changed?

Cheers,
g.
« Last Edit: February 24, 2015, 10:24:52 PM by Gene »

February 24, 2015, 10:31:20 PM
Reply #31

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
I see that BCM2835_BSC1_BASE is matching  0x3F804000 (BCM2835_PERI_BASE + 0x804000).
So just fixing the switch (didn't notice it before, otherwise would have fixed! =)).
Glad to see it's working.
Thanks!
g.

February 24, 2015, 10:39:25 PM
Reply #32

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
I think the output from GpioConnectionSettings.BoardConnectorRevision is right, it's all about the connector and that's rev3

In GetBscBase() shuffling the base address should probably only be done in case 3 and not in 1 and 2.

and yes, the modification you suggested works on RPi2 and you don't have to change the constants in the interop.

Regards,
Wibo.



February 24, 2015, 10:41:13 PM
Reply #33

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
All right, so I'm changing it like this:

Code: [Select]

        private static uint GetBscBase(ProcessorPin sdaPin, ProcessorPin sclPin)
        {
            switch (GpioConnectionSettings.BoardConnectorRevision)
            {
                case 1:
                    if (sdaPin == ProcessorPin.Pin0 && sclPin == ProcessorPin.Pin1)
                    return Interop.BCM2835_BSC0_BASE;
                    throw new InvalidOperationException("No I2C device exist on the specified pins");

                case 2:
                    if (sdaPin == ProcessorPin.Pin28 && sclPin == ProcessorPin.Pin29)
                        return Interop.BCM2835_BSC0_BASE;
                    if (sdaPin == ProcessorPin.Pin2 && sclPin == ProcessorPin.Pin3)
                        return Interop.BCM2835_BSC1_BASE;
                    throw new InvalidOperationException("No I2C device exist on the specified pins");

                case 3:
                    if (sdaPin == ProcessorPin.Pin2 && sclPin == ProcessorPin.Pin3)
                        return Board.Current.Model == '2' ? Interop.BCM2836_BSC1_BASE : Interop.BCM2835_BSC1_BASE;
                    throw new InvalidOperationException("No I2C device exist on the specified pins");

                default:
                    throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "Board revision {0} is not supported", GpioConnectionSettings.BoardConnectorRevision));
            }
        }



g.

February 24, 2015, 10:54:32 PM
Reply #34

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95

February 24, 2015, 10:55:54 PM
Reply #35

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer

February 24, 2015, 11:03:11 PM
Reply #36

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
Works and double checked if I removed the hack.
will test your release now...

There was an issue with the imported Automation program GPIO for the B+ running on the RPi2, maybe it's fixed too, I'll let you know.

BTW: Is there any chance the GPIO automation program for the B+ is adde by default in the HG installs?

Regards,
Wibo.

February 24, 2015, 11:24:32 PM
Reply #37

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
BTW: Is there any chance the GPIO automation program for the B+ is adde by default in the HG installs?

yes, where do I find the hgx for the GPIO B+ app?

g.

February 25, 2015, 12:00:52 AM
Reply #38

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
Checked your release at https://sourceforge.net/projects/homegenie/files/testing/

Only tested it on RPi2.
Have a test hgx to access I2c directly.
All hard coded and it never worked on RPi2, now it does :)

Will test HG GPIO tomorrow to see if there are any issues left.
Can't test SPI, since I have no SPI devices.

About the B+ and hopefully RPi2 GPIO hgx that are both rev3 connector.
You will get some lock violation if both casual and B+ are enabled, which is good, but not user friendly.
.

I use the attached hgx that was posted on the HG forum.

Regards,
Wibo.


February 25, 2015, 08:35:47 PM
Reply #39

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
Hi Gene,

just did some basic testing with GPIO, using your r480 testing release.
I used the GPIO hgx I posted yesterday.

Tested some pins in the GPIO rev2 range(26pins) and pins in the GPIO rev3 range(40pins).
The issue I had with my first tests never came back, it happened before you started to recognize the RPi2.

I didn't have other any other issues.

So it seems HG is working on RPi2 when it concerns GPIO and I2c.
I'm happy, because I have a sharp io library that works on RPi2.

Going to switch to HG raspberry-sharp-io fork for my own development.

Thanks for all the efforts and sharing info to make it work on RPi2.

Regards,
Wibo.




February 25, 2015, 09:07:22 PM
Reply #40

funworld

  • *
  • Information
  • Newbie
  • Posts: 20
Hi guys,

You all doing a great Job,Thanks for that.
I using your last r480 testing release.
and tested the GPIO rev3  that works on RPI 2,
but all I2C moduls still get an error,
  "Object of type 'HomeGenie.Automation.Scripting.ScriptingInstance' doesn't match target type 'HomeGenie.Automation.Scripting.ScriptingInstance'"

Regards,
funworld

February 25, 2015, 09:16:47 PM
Reply #41

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
@Wibo you're welcome, thank you too.

@funworld, the error probably means that you've to recompile that automation program, can you share the code?

g.

February 25, 2015, 09:39:02 PM
Reply #42

funworld

  • *
  • Information
  • Newbie
  • Posts: 20
Hello,
I use the standard SmartIC-MCP23017 but change low to high!

regards
funworld

February 26, 2015, 10:02:02 PM
Reply #43

funworld

  • *
  • Information
  • Newbie
  • Posts: 20
Hello, 

Now all work fine, I had connect a singel I2C device !

Thanks

Regards
Funworld

October 26, 2015, 06:12:36 PM
Reply #44

funworld

  • *
  • Information
  • Newbie
  • Posts: 20
Hi Gene,

In the new pre versions 497 and 498 the i2c with SmartIC - MCP23017 ditnĀ“t work on Raspi 2
Read operation failed with BCM2835_I2C_REASON_ERROR_NACK status

Thanks

Regards
Funworld