Page 3 of 3

Re: How to use 2 SC16IS752,I USE I2C

Posted: Mon Mar 25, 2019 8:35 am
by PhilE
Install one of the debug versions of the modules (you have read this thread, haven't you?) and then report the error messages.

Re: How to use 2 SC16IS752,I USE I2C

Posted: Mon Mar 25, 2019 10:27 am
by hnwangkg163
Should I also use the latest kernel for testing?
i think it is my kernel version problem

Code: Select all

[email protected]:/boot/overlays $ uname -r
4.14.50-v7+

Re: How to use 2 SC16IS752,I USE I2C

Posted: Mon Mar 25, 2019 10:35 am
by PhilE
The updated overlay should work for all affected kernel versions. The debug module (which just adds some more error messages and doesn't fix anything) has to match the running kernel version.

Re: How to use 2 SC16IS752,I USE I2C

Posted: Sat Nov 16, 2019 12:27 am
by sdmill
Hello,

My apologies for restarting this conversation - but as others have posted before me, I'm trying to utilize multiple of these Waveshare SC16IS752 cards for a project and am having some issues.

What I have found so far, all done within this last week, is that if I start with updating Buster completely, I am able to use one of the cards successfully. i2cdetect -y 1 displays both cards, (soldered for 0x48 and 0x49) but only prints UU for 49. 49 transmits and receives successfully while doing a loopback test. ls /dev/ttySC* also only shows SC0 and SC1.

If I update the kernel via rpi-update, all of a sudden I receive the additional serial ports (SC2 and SC3) and I can transmit successfully, but I can not receive. I wracked my brain for a bit before discovering that the IRQ pin on the chip would drop low as soon as I opened a terminal for the serial connection (like puTTY or miniterm). Watching it with a meter I can see the IRQ fall when the terminal is opened, rendering the port only able to Tx and rise again with the terminal was closed. I also noticed that I could still get it to momentarily work by applying a load (in this case a Sunfounder2004LCD) to the 5V bus which would momentarily cause the IRQ to go high and serial messages would appear in miniterm/puTTY. After perhaps a second it falls low again.

Any help would be greatly appreciated!

Re: How to use 2 SC16IS752,I USE I2C

Posted: Sat Nov 16, 2019 3:48 am
by sdmill
To amend my previous post, I identified a mistake I made creating the overlay assignments in the /boot/config.txt. I forgot the '=' in int_pin=XX. I've also determined that the lower board, 0x48, functions perfectly upon initial boot. It happens to be the lower board and I only took meter readings on the top. I can tie ttySC0 and SC1 (provided by 0x48) together and tx/rx successfully via miniterm/puTTY. 0x49 can still only tx however when I test it by tying it to the AMA0 port (I've disabled the BT uart via overlay=pi3-disable-bt).

Additionally, if I test 0x49's ports by tying them to 48's, then 48's stops working all together as well and requires a reboot to restore functionality.

Re: How to use 2 SC16IS752,I USE I2C

Posted: Sat Nov 16, 2019 6:29 pm
by sdmill
Aaand one last discovery, full functionality seems to follow which ever board is assigned int_pin=24.

I have tried assigning the int pin based on above posts and have tried 18 with no success. I’ve done a gpio readall to see other default low pins and have tried several with no change.

Re: How to use 2 SC16IS752,I USE I2C

Posted: Thu Dec 12, 2019 1:10 am
by manonline
PhilE wrote:
Fri Mar 22, 2019 4:37 pm
Can I keep the same interrupt int_pin=24 for the 2 modules or should the modules have different interrupt PIN ?
No - the interrupt pins have to be unique, otherwise the debug module will log an error like this:

Code: Select all

[   10.392344] sc16is7xx 1-0048: devm_request_irq -> -16
(Error 16 is EBUSY)

I'll update the standard overlay with this fix, then look for other overlays with similar potential issues.
oh, that's a bummer. I switched from SPI to I2C to avoid adding CS pins. I would hate to find myself in the same situation but with IRQ open-collector pins (you can stack them and serve all expansions in the same IRQ handler).

I may be saying nonsense, but is there a way to create virtual GPIOs you can assign to different device instances while having only one physical source?

I still don't have this problem, the project I'm talking is running on a custom Cortex-M4 board, but I'm already working on RPi-powered prototypes.

Thanks!

Re: How to use 2 SC16IS752,I USE I2C

Posted: Thu Dec 12, 2019 11:29 am
by PhilE
Linux is perfectly happy to share interrupts, but the driver has to request a shared interrupt otherwise it is assumed to be for its exclusive use. The sc16is7xx driver doesn't use the IRQF_SHARED flag, which may be as a result of it deferring all interrupt handling to a thread (because it can't use I2C to access registers with interrupts disabled).

It may be possible to hack the driver to allow shared use without having to make more substantial changes - how do you feel about building your own kernel (https://www.raspberrypi.org/documentati ... uilding.md)?

Re: How to use 2 SC16IS752,I USE I2C

Posted: Thu Dec 12, 2019 7:01 pm
by manonline
PhilE wrote:
Thu Dec 12, 2019 11:29 am
Linux is perfectly happy to share interrupts, but the driver has to request a shared interrupt otherwise it is assumed to be for its exclusive use. The sc16is7xx driver doesn't use the IRQF_SHARED flag, which may be as a result of it deferring all interrupt handling to a thread (because it can't use I2C to access registers with interrupts disabled).

It may be possible to hack the driver to allow shared use without having to make more substantial changes - how do you feel about building your own kernel (https://www.raspberrypi.org/documentati ... uilding.md)?
First I have to assemble a HAT with an extended I2C driver (P8B715) to connect the serial interfaces I already have. Already bought the HAT protoboard, connectors, drivers, etc. But I still have some projects in the queue :) I may be able to try it next weekend.

I have these serial Current Loop boards (and others with different phys) and, since I dumped SPI in favor of I2C, I can daisy-chain them. I only wire power, IRQ and I2C pins.

A quick solution without recompiling could be splitting the unique IRQ pin from boards into several RPi pins. An interrupt signal from any board will trigger several interrupts, the driver will handle all of them but only (kind of wasting time on idle boards, like with using shared interrupts), but a software solution would be soo much better.

SC16IS752 powered Current Loop interface
Image