armcapp
Posts: 9
Joined: Thu Jun 29, 2017 12:56 am

/dev/ttySC0 driver for sc16is750

Thu Jun 29, 2017 1:32 am

I'm trying to use the NXP I2C/SPI-to-UART device in a project and have enabled the ttySC0 driver by modifying config.txt:
dtoverlay=sc16is750-i2c,int_pin=24,addr=48

a few questions:
1) How do you change the baud rate from the default of 9600? For standard serial ports I use the "termios" struct.

2) config.txt seems to suggest it's possible to change the i2c address from 0x48, but it appears the slave address is always 0x48 no matter what value I change it to.

3) Is there any sample C code available showing how to use this driver? Searching the forum I've only found some python code.

armcapp
Posts: 9
Joined: Thu Jun 29, 2017 12:56 am

Re: /dev/ttySC0 driver for sc16is750

Fri Jun 30, 2017 11:14 am

So answering my own question, since the driver is similar to a standard serial port driver I used the termios struct and the cfsetospeed() call to change the baud rate.

Any idea how to tell how many bytes are in the rx buffer? I tried the ioctl FIONREAD but the "&bytes" argument is always 0.

armcapp
Posts: 9
Joined: Thu Jun 29, 2017 12:56 am

Re: /dev/ttySC0 driver for sc16is750

Fri Jun 30, 2017 2:30 pm

again answering my own question, it helps if you connect the IRQ pin to pin 24 of the Raspberry PI :) . Once I did that FIONREAD works as expected.

armcapp
Posts: 9
Joined: Thu Jun 29, 2017 12:56 am

Re: /dev/ttySC0 driver for sc16is750

Fri Jun 30, 2017 3:36 pm

One more question hopefully answered from someone other than myself :). In I2C mode wouldn't you need to set the SCL clock rate to 400KHz if you want to support serial reads of 115K on the NXP device?

armcapp
Posts: 9
Joined: Thu Jun 29, 2017 12:56 am

Re: /dev/ttySC0 driver for sc16is750

Fri Jun 30, 2017 4:39 pm

I'm just a wealth of information :). After changing the Pi SCL clock rate to 400KHz in config.txt, the NXP device supports incoming serial data at 115.2K.

Atique
Posts: 1
Joined: Mon Feb 26, 2018 10:00 am

Re: /dev/ttySC0 driver for sc16is750

Mon Feb 26, 2018 10:16 am

Hi,
I am just trying to interface sc16is750 using breakout board from sparkfun. But it seems its not really working. I was able to get the driver up and running but I2C bus seems to recognize the module and there is some activity on data line when I send data but nothing comes out of TX line of board.
Any help is appreciated.

bungee75
Posts: 2
Joined: Sat Oct 31, 2015 9:22 pm

Re: /dev/ttySC0 driver for sc16is750

Mon Nov 19, 2018 1:53 am

I have the SC16IS750 board and I did manage to enable the driver.
I am able to send some data through minicom to another instance of minicom that is connected to uart pins of RPi. But I can't receive any data through the SC board.

I connected the interrupt pin to gpio 24 and marked that in the config.txt file.
How can I debug the problem?

I also have two boards and both behave in same manner so I doubt it's HW problem.

bungee75
Posts: 2
Joined: Sat Oct 31, 2015 9:22 pm

Re: /dev/ttySC0 driver for sc16is750

Mon Nov 19, 2018 4:56 pm

So I'll answer my own question.

SC16IS750 IRQ pin has to have pull-up resistor to 3.3V line. If you omit that it will not work as overlay driver depends on the interrupt.

So minimum connection is as follows:
  • IRQ (pull-up to 3.3V via 100k resistor [can be any value between 10k~100k]) to dedicated GPIO pin (GPIO24) in my case
  • Vcc (3.3v) and Gnd
  • SDA and SCL to respective gpio pins on RPi
  • A0 and A1 to GND (this can be tied to other configuration to change address)
  • I2C/SPI to 3.3V for I2C operation
  • Reset to 3.3V to be sure
In my /boot/config.txt I added:

Code: Select all

dtoverlay=sc16is750-i2c,addr=0x4D,int_pin=24,fixed-clock=14745600
I don't know if fixed-clock parameter is actually needed but as this configuration works I left it there.

parthgulati
Posts: 1
Joined: Fri Oct 25, 2019 5:23 am

Re: /dev/ttySC0 driver for sc16is750

Tue Nov 05, 2019 5:23 am

Hi,
I am trying to use this i2c to uart convertor for my project. Can you tell me from where you got the driver code. Any help is appreciated.
Thanks

nopnop2002
Posts: 20
Joined: Sat Sep 28, 2013 11:40 am

Re: /dev/ttySC0 driver for sc16is750

Mon Nov 11, 2019 7:28 am

There is example code for SC16IS752.

https://www.waveshare.com/wiki/Serial_Expansion_HAT

Peero
Posts: 4
Joined: Sun Nov 03, 2019 10:40 am

Re: /dev/ttySC0 driver for sc16is750

Wed Nov 13, 2019 3:10 am

I should probably post this in another thread, but I have modified the driver for the sc12xx series UART so you can use CMPAR for 9 bit comms. I have it tested and working on a current project.

If there is enough interested, I will seek out some help from the more experienced about adding this change into the official channels. I have never used git or never developed on open source before so its a bit of a learning curve. Talk about a baptism of fire!

I will eventually contribute this change anyway, provided someone does not beat me to it.

Return to “Interfacing (DSI, CSI, I2C, etc.)”